[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3378.1473092663@warthog.procyon.org.uk>
Date: Mon, 05 Sep 2016 17:24:23 +0100
From: David Howells <dhowells@...hat.com>
To: David Laight <David.Laight@...LAB.COM>,
Jeffrey Altman <jaltman@...istor.com>
Cc: dhowells@...hat.com,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-afs@...ts.infradead.org" <linux-afs@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values
[cc'ing Jeff Altman for comment]
David Laight <David.Laight@...LAB.COM> wrote:
> > Create a random epoch value rather than a time-based one on startup and set
> > the top bit to indicate that this is the case.
>
> Why set the top bit?
> There is nothing to stop the time (in seconds) from having the top bit set.
> Nothing else can care - otherwise this wouldn't work.
This is what I'm told I should do by purveyors of other RxRPC solutions.
> > Also create a random starting client connection ID value. This will be
> > incremented from here as new client connections are created.
>
> I'm guessing this is to make duplicates less likely after a restart?
Again, it's been suggested that I do this, but I would guess so.
> You may want to worry about duplicate allocations (after 2^32 connects).
It's actually a quarter of that, but connection != call, so a connection may
be used for up to ~16 billion RPC operations before it *has* to be flushed.
> There are id allocation algorithms that guarantee not to generate duplicates
> and not to reuse values quickly while still being fixed cost.
> Look at the code NetBSD uses to allocate process ids for an example.
I'm using idr_alloc_cyclic()[*] with a fixed size "window" on the active conn
ID values. Client connections with IDs outside of that window are discarded
as soon as possible to keep the memory consumption of the tree down (and to
force security renegotiation occasionally). However, given that there are a
billion IDs to cycle through, it will take quite a while for reuse to become
an issue.
I like the idea of incrementing the epoch every time we cycle through the ID
space, but I'm told that a change in the epoch value is an indication that the
client rebooted - with what consequences I cannot say.
[*] which is what Linux uses to allocate process IDs.
David
Powered by blists - more mailing lists