> -----Original Message-----
> From: David Miller <da...@davemloft.net>
> Sent: Thursday, January 31, 2019 11:30 AM
> To: Vakul Garg <vakul.g...@nxp.com>
> Cc: netdev@vger.kernel.org; bor...@mellanox.com;
> avia...@mellanox.com; davejwat...@fb.com; doro...@fb.com
> Subject: Re: [PATCH net-next] strparser: Return if socket does not have
> required number of bytes
> 
> From: Vakul Garg <vakul.g...@nxp.com>
> Date: Wed, 30 Jan 2019 07:31:44 +0000
> 
> > Function strp_data_ready() should peek the associated socket to check
> > whether it has the required number of bytes available before queueing
> > work or initiating socket read via strp_read_sock(). This saves cpu
> > cycles because strp_read_sock() is called only when required amount of
> > data is available.
> >
> > Signed-off-by: Vakul Garg <vakul.g...@nxp.com>
> 
> You can't do this, I think.  It's racy and the user socket owned check is
> absolutely necessary before you do the need bytes check.

Do you mean to say that 'peek_len' operation can't be invoked if the socket is 
already owned by some other context?

My understanding by reading following link is that we can to peek_len operation 
without acquiring sock lock.

https://elixir.bootlin.com/linux/v5.0-rc4/source/include/linux/net.h#L191

Can you please kindly elaborate the problem?

Reply via email to