All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Rao Shoaib <rao.shoaib@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-kernel@vger.kernel.org, brouer@redhat.com,
	linux-mm@kvack.org
Subject: Re: [PATCH] Move kfree_call_rcu() to slab_common.c
Date: Thu, 21 Dec 2017 17:39:37 -0800	[thread overview]
Message-ID: <20171222013937.GA7829@linux.vnet.ibm.com> (raw)
In-Reply-To: <44044955-1ef9-1d1e-5311-d8edc006b812@oracle.com>

On Thu, Dec 21, 2017 at 09:31:23AM -0800, Rao Shoaib wrote:
> 
> 
> On 12/21/2017 04:36 AM, Matthew Wilcox wrote:
> >On Thu, Dec 21, 2017 at 12:19:47AM -0800, rao.shoaib@oracle.com wrote:
> >>This patch moves kfree_call_rcu() and related macros out of rcu code. A new
> >>function __call_rcu_lazy() is created for calling __call_rcu() with the lazy
> >>flag.
> >Something you probably didn't know ... there are two RCU implementations
> >in the kernel; Tree and Tiny.  It looks like you've only added
> >__call_rcu_lazy() to Tree and you'll also need to add it to Tiny.
> I left it out on purpose because the call in tiny is a little different
> 
> rcutiny.h:
> 
> static inline void kfree_call_rcu(struct rcu_head *head,
>                   void (*func)(struct rcu_head *rcu))
> {
>     call_rcu(head, func);
> }
> 
> tree.c:
> 
> void kfree_call_rcu(struct rcu_head *head,
>             void (*func)(struct rcu_head *rcu))
> {
>     __call_rcu(head, func, rcu_state_p, -1, 1);
> }
> EXPORT_SYMBOL_GPL(kfree_call_rcu);
> 
> If we want the code to be exactly same I can create a lazy version
> for tiny as well. However,  I don not know where to move
> kfree_call_rcu() from it's current home in rcutiny.h though. Any
> thoughts ?

I might be missing something subtle here, but in case I am not, my
suggestion is to simply rename rcutiny.h's kfree_call_rcu() and otherwise
leave it as is.  If you want to update the type of the second argument,
which got missed back in the day, there is always this:

static inline void call_rcu_lazy(struct rcu_head *head, rcu_callback_t func)
{
	call_rcu(head, func);
}

The reason that Tiny RCU doesn't handle laziness specially is because
Tree RCU's handling of laziness is a big no-op on the single CPU systems
on which Tiny RCU runs.  So Tiny RCU need do nothing special to support
laziness.

							Thanx, Paul

> >>Also moving macros generated following checkpatch noise. I do not know
> >>how to silence checkpatch as there is nothing wrong.
> >>
> >>CHECK: Macro argument reuse 'offset' - possible side-effects?
> >>#91: FILE: include/linux/slab.h:348:
> >>+#define __kfree_rcu(head, offset) \
> >>+	do { \
> >>+		BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
> >>+		kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
> >>+	} while (0)
> >What checkpatch is warning you about here is that somebody might call
> >
> >__kfree_rcu(p, a++);
> >
> >and this would expand into
> >
> >	do { \
> >		BUILD_BUG_ON(!__is_kfree_rcu_offset(a++)); \
> >		kfree_call_rcu(p, (rcu_callback_t)(unsigned long)(a++)); \
> >	} while (0)
> >
> >which would increment 'a' twice, and cause pain and suffering.
> >
> >That's pretty unlikely usage of __kfree_rcu(), but I suppose it's not
> >impossible.  We have various hacks to get around this kind of thing;
> >for example I might do this as::
> >
> >#define __kfree_rcu(head, offset) \
> >	do { \
> >		unsigned long __o = offset;
> >		BUILD_BUG_ON(!__is_kfree_rcu_offset(__o)); \
> >		kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(__o)); \
> >	} while (0)
> >
> >Now offset is only evaluated once per invocation of the macro.  The other
> >two warnings are the same problem.
> >
> Thanks. I was not sure if I was required to fix the noise or based
> on inspection the noise could be ignored. I will make the change and
> resubmit.
> 
> Shoaib
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Rao Shoaib <rao.shoaib@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-kernel@vger.kernel.org, brouer@redhat.com,
	linux-mm@kvack.org
Subject: Re: [PATCH] Move kfree_call_rcu() to slab_common.c
Date: Thu, 21 Dec 2017 17:39:37 -0800	[thread overview]
Message-ID: <20171222013937.GA7829@linux.vnet.ibm.com> (raw)
In-Reply-To: <44044955-1ef9-1d1e-5311-d8edc006b812@oracle.com>

On Thu, Dec 21, 2017 at 09:31:23AM -0800, Rao Shoaib wrote:
> 
> 
> On 12/21/2017 04:36 AM, Matthew Wilcox wrote:
> >On Thu, Dec 21, 2017 at 12:19:47AM -0800, rao.shoaib@oracle.com wrote:
> >>This patch moves kfree_call_rcu() and related macros out of rcu code. A new
> >>function __call_rcu_lazy() is created for calling __call_rcu() with the lazy
> >>flag.
> >Something you probably didn't know ... there are two RCU implementations
> >in the kernel; Tree and Tiny.  It looks like you've only added
> >__call_rcu_lazy() to Tree and you'll also need to add it to Tiny.
> I left it out on purpose because the call in tiny is a little different
> 
> rcutiny.h:
> 
> static inline void kfree_call_rcu(struct rcu_head *head,
>                   void (*func)(struct rcu_head *rcu))
> {
>     call_rcu(head, func);
> }
> 
> tree.c:
> 
> void kfree_call_rcu(struct rcu_head *head,
>             void (*func)(struct rcu_head *rcu))
> {
>     __call_rcu(head, func, rcu_state_p, -1, 1);
> }
> EXPORT_SYMBOL_GPL(kfree_call_rcu);
> 
> If we want the code to be exactly same I can create a lazy version
> for tiny as well. However,  I don not know where to move
> kfree_call_rcu() from it's current home in rcutiny.h though. Any
> thoughts ?

I might be missing something subtle here, but in case I am not, my
suggestion is to simply rename rcutiny.h's kfree_call_rcu() and otherwise
leave it as is.  If you want to update the type of the second argument,
which got missed back in the day, there is always this:

static inline void call_rcu_lazy(struct rcu_head *head, rcu_callback_t func)
{
	call_rcu(head, func);
}

The reason that Tiny RCU doesn't handle laziness specially is because
Tree RCU's handling of laziness is a big no-op on the single CPU systems
on which Tiny RCU runs.  So Tiny RCU need do nothing special to support
laziness.

							Thanx, Paul

> >>Also moving macros generated following checkpatch noise. I do not know
> >>how to silence checkpatch as there is nothing wrong.
> >>
> >>CHECK: Macro argument reuse 'offset' - possible side-effects?
> >>#91: FILE: include/linux/slab.h:348:
> >>+#define __kfree_rcu(head, offset) \
> >>+	do { \
> >>+		BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
> >>+		kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
> >>+	} while (0)
> >What checkpatch is warning you about here is that somebody might call
> >
> >__kfree_rcu(p, a++);
> >
> >and this would expand into
> >
> >	do { \
> >		BUILD_BUG_ON(!__is_kfree_rcu_offset(a++)); \
> >		kfree_call_rcu(p, (rcu_callback_t)(unsigned long)(a++)); \
> >	} while (0)
> >
> >which would increment 'a' twice, and cause pain and suffering.
> >
> >That's pretty unlikely usage of __kfree_rcu(), but I suppose it's not
> >impossible.  We have various hacks to get around this kind of thing;
> >for example I might do this as::
> >
> >#define __kfree_rcu(head, offset) \
> >	do { \
> >		unsigned long __o = offset;
> >		BUILD_BUG_ON(!__is_kfree_rcu_offset(__o)); \
> >		kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(__o)); \
> >	} while (0)
> >
> >Now offset is only evaluated once per invocation of the macro.  The other
> >two warnings are the same problem.
> >
> Thanks. I was not sure if I was required to fix the noise or based
> on inspection the noise could be ignored. I will make the change and
> resubmit.
> 
> Shoaib
> 

  reply	other threads:[~2017-12-22  1:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21  8:19 [PATCH] Move kfree_call_rcu() to slab_common.c rao.shoaib
2017-12-21  8:19 ` rao.shoaib
2017-12-21 12:36 ` Matthew Wilcox
2017-12-21 12:36   ` Matthew Wilcox
2017-12-21 17:31   ` Rao Shoaib
2017-12-21 17:31     ` Rao Shoaib
2017-12-22  1:39     ` Paul E. McKenney [this message]
2017-12-22  1:39       ` Paul E. McKenney
2017-12-22  3:17       ` Rao Shoaib
2018-01-02 20:24         ` Paul E. McKenney
2018-01-02 20:24           ` Paul E. McKenney
2017-12-21 15:54 ` Paul E. McKenney
2017-12-21 15:54   ` Paul E. McKenney
2017-12-21 17:06   ` Matthew Wilcox
2017-12-21 17:06     ` Matthew Wilcox
2017-12-22  1:27     ` Paul E. McKenney
2017-12-22  1:27       ` Paul E. McKenney
2017-12-22  1:30       ` Paul E. McKenney
2017-12-22  1:30         ` Paul E. McKenney

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=20171222013937.GA7829@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=brouer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rao.shoaib@oracle.com \
    --cc=willy@infradead.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 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.