All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Amir Goldstein <amir73il@gmail.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] fs: Do not check if there is a fsnotify watcher on pseudo inodes
Date: Mon, 29 Jun 2020 20:48:35 +0200	[thread overview]
Message-ID: <20200629184835.GK26507@quack2.suse.cz> (raw)
In-Reply-To: <4f6c8dab-4b54-d523-8636-2b01c03d14d3@gmail.com>

On Mon 29-06-20 08:17:02, Eric Dumazet wrote:
> On 6/16/20 12:47 AM, Jan Kara wrote:
> > On Mon 15-06-20 19:26:38, Amir Goldstein wrote:
> >>> This patch changes alloc_file_pseudo() to always opt out of fsnotify by
> >>> setting FMODE_NONOTIFY flag so that no check is made for fsnotify watchers
> >>> on pseudo files. This should be safe as the underlying helper for the
> >>> dentry is d_alloc_pseudo which explicitly states that no lookups are ever
> >>> performed meaning that fanotify should have nothing useful to attach to.
> >>>
> >>> The test motivating this was "perf bench sched messaging --pipe". On
> >>> a single-socket machine using threads the difference of the patch was
> >>> as follows.
> >>>
> >>>                               5.7.0                  5.7.0
> >>>                             vanilla        nofsnotify-v1r1
> >>> Amean     1       1.3837 (   0.00%)      1.3547 (   2.10%)
> >>> Amean     3       3.7360 (   0.00%)      3.6543 (   2.19%)
> >>> Amean     5       5.8130 (   0.00%)      5.7233 *   1.54%*
> >>> Amean     7       8.1490 (   0.00%)      7.9730 *   2.16%*
> >>> Amean     12     14.6843 (   0.00%)     14.1820 (   3.42%)
> >>> Amean     18     21.8840 (   0.00%)     21.7460 (   0.63%)
> >>> Amean     24     28.8697 (   0.00%)     29.1680 (  -1.03%)
> >>> Amean     30     36.0787 (   0.00%)     35.2640 *   2.26%*
> >>> Amean     32     38.0527 (   0.00%)     38.1223 (  -0.18%)
> >>>
> >>> The difference is small but in some cases it's outside the noise so
> >>> while marginal, there is still some small benefit to ignoring fsnotify
> >>> for files allocated via alloc_file_pseudo in some cases.
> >>>
> >>> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
> >>
> >> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> > 
> > Thanks for the patch Mel and for review Amir! I've added the patch to my
> > tree with small amendments to the changelog.
> > 
> > 								Honza
> > 
> 
> Note this patch broke some user programs (one instance being packetdrill)
> 
> Typical legacy packetdrill script has :
> 
> // Create a socket and set it to non-blocking.
>     0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
>    +0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
>    +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
> 
> 
> But after this change, fcntl(3, F_GETFL) returns 0x4000002 
> 
> FMODE_NONOTIFY was not meant to be visible to user space. (otherwise
> there would be a O_NONOTIFY) ?

Interesting. As Mel said the patch is reverted anyway (Linus already
applied the revert) but the question about FMODE_NONOTIFY is interesting.
Userspace certainly cannot set the flag (the kernel enforces this on
open(2) and fcntl(F_SETFL)). But it is visible to userspace via
fcntl(F_GETFL) which may have been an oversight... I'm just not sure
whether some of the fanotify(7) users which legitimately get such file
descriptors don't depend on this flag being visible.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2020-06-29 18:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 12:13 [PATCH v2] fs: Do not check if there is a fsnotify watcher on pseudo inodes Mel Gorman
2020-06-15 16:26 ` Amir Goldstein
2020-06-15 17:25   ` Mel Gorman
2020-06-15 18:32     ` Amir Goldstein
2020-06-16  7:47   ` Jan Kara
2020-06-29 15:17     ` Eric Dumazet
2020-06-29 15:29       ` Mel Gorman
2020-06-29 18:48       ` Jan Kara [this message]
2020-06-19  8:51 ` [fs] 0587211dff: will-it-scale.per_thread_ops 4.7% improvement kernel test robot
2020-06-19  8:51   ` kernel test robot

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=20200629184835.GK26507@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.