linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: imandevel@gmail.com
Cc: jack@suse.cz, amir73il@gmail.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] inotify: set ret in inotify_read() to -EAGAIN only when O_NONBLOCK is set
Date: Sun, 1 Sep 2024 15:00:57 +0800	[thread overview]
Message-ID: <ZtQRKfuawk6borTL@visitorckw-System-Product-Name> (raw)
In-Reply-To: <20240901030150.76054-1-ImanDevel@gmail.com>

On Sat, Aug 31, 2024 at 11:01:50PM -0400, imandevel@gmail.com wrote:
> From: Iman Seyed <ImanDevel@gmail.com>
> 
> Avoid setting ret to -EAGAIN unnecessarily. Only set
> it when O_NONBLOCK is specified; otherwise, leave ret
> unchanged and proceed to set it to -ERESTARTSYS.
>

Hi Iman,

Have you checked the code generated by gcc before and after applying
this patch? My intuition suggests that the compiler optimization might
result in the same code being produced.

Regards,
Kuan-Wei

> Signed-off-by: Iman Seyed <ImanDevel@gmail.com>
> ---
>  fs/notify/inotify/inotify_user.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 4ffc30606e0b..d5d4b306a33d 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -279,9 +279,11 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
>  			continue;
>  		}
>  
> -		ret = -EAGAIN;
> -		if (file->f_flags & O_NONBLOCK)
> +		if (file->f_flags & O_NONBLOCK) {
> +			ret = -EAGAIN;
>  			break;
> +		}
> +
>  		ret = -ERESTARTSYS;
>  		if (signal_pending(current))
>  			break;
> -- 
> 2.46.0
> 

  reply	other threads:[~2024-09-01  7:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-01  3:01 [PATCH] inotify: set ret in inotify_read() to -EAGAIN only when O_NONBLOCK is set imandevel
2024-09-01  7:00 ` Kuan-Wei Chiu [this message]
2024-09-01  7:35   ` Iman Seyed
2024-09-02 14:04 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZtQRKfuawk6borTL@visitorckw-System-Product-Name \
    --to=visitorckw@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=imandevel@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).