Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-06 Thread Jan Kara
On Wed 01-08-18 10:46:35, Dmitry Vyukov wrote: > I guess it would be useful to have such extensive comment for each > SLAB_TYPESAFE_BY_RCU use explaining why it is needed and how all the > tricky aspects are handled. > > For example, the one in jbd2 is interesting because it memsets the > whole

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 1:40 PM, Florian Westphal wrote: > Dmitry Vyukov wrote: >> On Wed, Aug 1, 2018 at 12:35 PM, Florian Westphal wrote: >> > Dmitry Vyukov wrote: >> >> Still can't grasp all details. >> >> There is state that we read without taking ct->ct_general.use ref >> >> first, namely

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Florian Westphal
Dmitry Vyukov wrote: > Still can't grasp all details. > There is state that we read without taking ct->ct_general.use ref > first, namely ct->state and what's used by nf_ct_key_equal. > So let's say the entry we want to find is in the list, but > nf_conntrack_find finds a wrong entry earlier

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On 08/01/2018 03:34 AM, Dmitry Vyukov wrote: > On Wed, Aug 1, 2018 at 12:23 PM, Eric Dumazet wrote: >> On 08/01/2018 02:03 AM, Andrey Ryabinin wrote: >> >>> I can't think of any advantage in not having the constructor. >> >> I can't see any advantage adding another indirect call, >> in

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Tue, Jul 31, 2018 at 8:51 PM, Linus Torvalds wrote: > On Tue, Jul 31, 2018 at 10:49 AM Linus Torvalds > wrote: >> >> So the re-use might initialize the fields lazily, not necessarily using a >> ctor. > > In particular, the pattern that nf_conntrack uses looks like it is safe. > > If you have

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 6:25 PM, Eric Dumazet wrote: > On 08/01/2018 09:22 AM, Christopher Lameter wrote: >> On Wed, 1 Aug 2018, Eric Dumazet wrote: >> >>> The idea of having a ctor() would only be a win if all the fields that >>> can be initialized in the ctor are contiguous and fill an integral

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Christopher Lameter
On Wed, 1 Aug 2018, Eric Dumazet wrote: > The idea of having a ctor() would only be a win if all the fields that > can be initialized in the ctor are contiguous and fill an integral > number of cache lines. Ok. Its reducing code size and makes the object status more consistent. Isn't that

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 3:46 PM, Florian Westphal wrote: > Dmitry Vyukov wrote: >> If that scenario is possible that a fix would be to make > > Looks possible. > >> __nf_conntrack_find_get ever return NULL iff it got NULL from >> nf_conntrack_find (not if any of the checks has failed). > > I

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 1:28 PM, Eric Dumazet wrote: > On 08/01/2018 03:34 AM, Dmitry Vyukov wrote: >> On Wed, Aug 1, 2018 at 12:23 PM, Eric Dumazet wrote: >>> On 08/01/2018 02:03 AM, Andrey Ryabinin wrote: >>> I can't think of any advantage in not having the constructor. >>> >>> I can't see

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 12:35 PM, Florian Westphal wrote: > Dmitry Vyukov wrote: >> Still can't grasp all details. >> There is state that we read without taking ct->ct_general.use ref >> first, namely ct->state and what's used by nf_ct_key_equal. >> So let's say the entry we want to find is in

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On Wed, Aug 1, 2018 at 8:15 AM Christopher Lameter wrote: > > On Wed, 1 Aug 2018, Dmitry Vyukov wrote: > > > But we are trading 1 indirect call for comparable overhead removed > > from much more common path. The path that does ctors is also calling > > into page alloc, which is much more

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On 08/01/2018 09:22 AM, Christopher Lameter wrote: > On Wed, 1 Aug 2018, Eric Dumazet wrote: > >> The idea of having a ctor() would only be a win if all the fields that >> can be initialized in the ctor are contiguous and fill an integral >> number of cache lines. > > Ok. Its reducing code

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 5:37 PM, Eric Dumazet wrote: > On Wed, Aug 1, 2018 at 8:15 AM Christopher Lameter wrote: >> >> On Wed, 1 Aug 2018, Dmitry Vyukov wrote: >> >> > But we are trading 1 indirect call for comparable overhead removed >> > from much more common path. The path that does ctors is

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On Tue, Jul 31, 2018 at 10:10 AM Florian Westphal wrote: > > Andrey Ryabinin wrote: > > Guys, it seems that we have a lot of code using SLAB_TYPESAFE_BY_RCU cache > > without constructor. > > I think it's nearly impossible to use that combination without having bugs. > > It's either you don't

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 10:46 AM, Dmitry Vyukov wrote: > On Tue, Jul 31, 2018 at 8:51 PM, Linus Torvalds > wrote: >> On Tue, Jul 31, 2018 at 10:49 AM Linus Torvalds >> wrote: >>> >>> So the re-use might initialize the fields lazily, not necessarily using a >>> ctor. >> >> In particular, the

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On 08/01/2018 02:03 AM, Andrey Ryabinin wrote: > I can't think of any advantage in not having the constructor. > I can't see any advantage adding another indirect call, in RETPOLINE world. ___ dri-devel mailing list

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Tue, Jul 31, 2018 at 7:41 PM, Eric Dumazet wrote: > On Tue, Jul 31, 2018 at 10:36 AM Christopher Lameter wrote: > >> >> If there is refcounting going on then why use SLAB_TYPESAFE_BY_RCU? > > To allow fast reuse of objects, without going through call_rcu() and > reducing cache efficiency. > >

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Andrey Ryabinin
On 07/31/2018 09:51 PM, Linus Torvalds wrote: > On Tue, Jul 31, 2018 at 10:49 AM Linus Torvalds > wrote: >> >> So the re-use might initialize the fields lazily, not necessarily using a >> ctor. > > In particular, the pattern that nf_conntrack uses looks like it is safe. > > If you have a

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On Tue, Jul 31, 2018 at 10:51 AM Dmitry Vyukov wrote: > > > Is it OK to overwrite ct->status? It seems that are some read and > writes to it right after atomic_inc_not_zero. If it is after a (successful) atomic_inc_not_zero(), the object is guaranteed to be alive (not freed or about to be

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Christopher Lameter
On Wed, 1 Aug 2018, Dmitry Vyukov wrote: > But we are trading 1 indirect call for comparable overhead removed > from much more common path. The path that does ctors is also calling > into page alloc, which is much more expensive. > So ctor should be a net win on performance front, no? ctor would

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On Tue, Jul 31, 2018 at 10:36 AM Christopher Lameter wrote: > > If there is refcounting going on then why use SLAB_TYPESAFE_BY_RCU? To allow fast reuse of objects, without going through call_rcu() and reducing cache efficiency. I believe this is mentioned in Documentation/RCU/rculist_nulls.txt

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Dmitry Vyukov
On Wed, Aug 1, 2018 at 12:23 PM, Eric Dumazet wrote: > On 08/01/2018 02:03 AM, Andrey Ryabinin wrote: > >> I can't think of any advantage in not having the constructor. > > I can't see any advantage adding another indirect call, > in RETPOLINE world. Can you please elaborate what's the problem

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Christopher Lameter
On Tue, 31 Jul 2018, Andrey Ryabinin wrote: > Guys, it seems that we have a lot of code using SLAB_TYPESAFE_BY_RCU cache > without constructor. > I think it's nearly impossible to use that combination without having bugs. > It's either you don't really need the SLAB_TYPESAFE_BY_RCU, or you need

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Florian Westphal
Dmitry Vyukov wrote: > If that scenario is possible that a fix would be to make Looks possible. > __nf_conntrack_find_get ever return NULL iff it got NULL from > nf_conntrack_find (not if any of the checks has failed). I don't see why we need to restart on nf_ct_is_dying(), but other than

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Florian Westphal
Andrey Ryabinin wrote: > Guys, it seems that we have a lot of code using SLAB_TYPESAFE_BY_RCU cache > without constructor. > I think it's nearly impossible to use that combination without having bugs. > It's either you don't really need the SLAB_TYPESAFE_BY_RCU, or you need to > have a

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Florian Westphal
Dmitry Vyukov wrote: > On Wed, Aug 1, 2018 at 12:35 PM, Florian Westphal wrote: > > Dmitry Vyukov wrote: > >> Still can't grasp all details. > >> There is state that we read without taking ct->ct_general.use ref > >> first, namely ct->state and what's used by nf_ct_key_equal. > >> So let's say

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-08-02 Thread Eric Dumazet
On Wed, Aug 1, 2018 at 9:47 AM Dmitry Vyukov wrote: > > Proving with numbers is required for a claimed performance improvement > at the cost of code degradation/increase. For a win-win change there > is really nothing to prove. You have to _prove_ it is a win-win. It is not sufficient to claim

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-07-31 Thread Linus Torvalds
On Tue, Jul 31, 2018 at 10:49 AM Linus Torvalds wrote: > > So the re-use might initialize the fields lazily, not necessarily using a > ctor. In particular, the pattern that nf_conntrack uses looks like it is safe. If you have a well-defined refcount, and use "atomic_inc_not_zero()" to guard

Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)

2018-07-31 Thread Linus Torvalds
On Tue, Jul 31, 2018 at 10:36 AM Christopher Lameter wrote: > > If there is refcounting going on then why use SLAB_TYPESAFE_BY_RCU? .. because the object can be accessed (by RCU) after the refcount has gone down to zero, and the thing has been released. That's the whole and only point of