linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	David Miller <davem@davemloft.net>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Network Development <netdev@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [Bug 106241] New: shutdown(3)/close(3) behaviour is incorrect for sockets in accept(3)
Date: Fri, 30 Oct 2015 21:02:15 +0000	[thread overview]
Message-ID: <20151030210215.GI22011@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFx_BQG4FzSuyL2KAz=c+R0cPv0ZpjboT_=yKjZNGmTUEg@mail.gmail.com>

On Fri, Oct 30, 2015 at 10:18:12AM -0700, Linus Torvalds wrote:

> I do wonder if we couldn't just speed up the bitmap allocator by an
> order of magnitude. It would be nicer to be able to make existing
> loads faster without any new "don't bother with POSIX semantics" flag.
> 
> We could, for example, extend the "open_fds" bitmap with a
> "second-level" bitmap that has information on when the first level is
> full. We traverse the open_fd's bitmap one word at a time anyway, we
> could have a second-level bitmap that has one bit per word to say
> whether that word is already full.

Your variant has 1:64 ratio; obviously better than now, but we can actually
do 1:bits-per-cacheline quite easily.

I've been playing with a variant that has more than two bitmaps, and
AFAICS it
	a) does not increase the amount of cacheline pulled and
	b) keeps it well-bound even in the absolutely worst case
(128M-odd descriptors filled, followed by close(0);dup2(1,0); -
in that case it ends up accessing the 7 cachelines worth of
bitmaps; your variant will read through 4000-odd cachelines of
the summary bitmap alone; the mainline is even worse).

> The advantage of the above is that it should just work for existing
> binaries. It may not be quite as optimal as just introducing a new
> "don't care about POSIX" feature, but quite frankly, if it cuts down
> the bad case of "find_next_zero_bit()" by a factror of 64 (and then
> adds a *small* expense factor on top of that), I suspect it should be
> "good enough" even for your nasty case.
> 
> What do you think? Willing to try the above approach (with any
> inevitable bug-fixes) and see how it compares?
> 
> Obviously in addition to any fixes to my pseudo-code above you'd need
> to add the allocations for the new "full_fds_bits" etc, but I think it
> should be easy to make the full_fds_bit allocation be *part* of the
> "open_fds" allocation, so you wouldn't need a new allocation in
> alloc_fdtable(). We already do that whole "use a single allocation" to
> combine open_fds with close_on_exec into one single allocation.

I'll finish testing what I've got and post it; it costs 3 extra pointers
in the files_struct and a bit fatter bitmap allocation (less than 0.2%
extra).  All the arguments regarding the unmodified binaries apply, of
course, and so far it looks fairly compact...

  reply	other threads:[~2015-10-30 21:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201510221824.t9MIOp6n003978@room101.nl.oracle.com>
     [not found] ` <20151022190701.GV22011@ZenIV.linux.org.uk>
     [not found]   ` <201510221951.t9MJp5LC005892@room101.nl.oracle.com>
     [not found]     ` <20151022215741.GW22011@ZenIV.linux.org.uk>
     [not found]       ` <201510230952.t9N9qYZJ021998@room101.nl.oracle.com>
     [not found]         ` <20151024023054.GZ22011@ZenIV.linux.org.uk>
     [not found]           ` <201510270908.t9R9873a001683@room101.nl.oracle.com>
     [not found]             ` <562F577E.6000901@oracle.com>
     [not found]               ` <20151027231702.GA22011@ZenIV.linux.org.uk>
     [not found]                 ` <1445991236.7476.59.camel@edumazet-glaptop2.roam.corp.google.com>
2015-10-28 12:35                   ` [Bug 106241] New: shutdown(3)/close(3) behaviour is incorrect for sockets in accept(3) Al Viro
2015-10-28 13:24                     ` Eric Dumazet
2015-10-28 14:47                       ` Eric Dumazet
2015-10-28 21:13                         ` Al Viro
2015-10-28 21:44                           ` Eric Dumazet
2015-10-28 22:33                             ` Al Viro
2015-10-28 23:08                               ` Eric Dumazet
2015-10-29  0:15                                 ` Al Viro
2015-10-29  3:29                                   ` Eric Dumazet
2015-10-29  4:16                                     ` Al Viro
2015-10-29 12:35                                       ` Eric Dumazet
2015-10-29 13:48                                         ` Eric Dumazet
2015-10-30 17:18                                         ` Linus Torvalds
2015-10-30 21:02                                           ` Al Viro [this message]
2015-10-30 21:23                                             ` Linus Torvalds
2015-10-30 21:50                                               ` Linus Torvalds
2015-10-30 22:33                                                 ` Al Viro
2015-10-30 23:52                                                   ` Linus Torvalds
2015-10-31  0:09                                                     ` Al Viro
2015-10-31 15:59                                                     ` Eric Dumazet
2015-10-31 19:34                                                     ` Al Viro
2015-10-31 19:54                                                       ` Linus Torvalds
2015-10-31 20:29                                                         ` Al Viro
2015-11-02  0:24                                                           ` Al Viro
2015-11-02  0:59                                                             ` Linus Torvalds
2015-11-02  2:14                                                             ` Eric Dumazet
2015-11-02  6:22                                                               ` Al Viro
2015-10-31 20:45                                                         ` Eric Dumazet
2015-10-31 21:23                                                           ` Linus Torvalds
2015-10-31 21:51                                                             ` Al Viro
2015-10-31 22:34                                                             ` Eric Dumazet
2015-10-31  1:07                                                 ` Eric Dumazet

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=20151030210215.GI22011@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=torvalds@linux-foundation.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).