public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: paulmck@linux.vnet.ibm.com
Cc: dhowells@redhat.com, Lai Jiangshan <laijs@cn.fujitsu.com>,
	Ingo Molnar <mingo@elte.hu>, James Morris <jmorris@namei.org>,
	keyrings@linux-nfs.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 31/36] security,rcu: convert call_rcu(user_update_rcu_disposal) to kfree_rcu()
Date: Fri, 01 Apr 2011 16:27:09 +0100	[thread overview]
Message-ID: <8112.1301671629@redhat.com> (raw)
In-Reply-To: <20110331190428.GI2258@linux.vnet.ibm.com>

Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:

> commit 316b740440ea0a54615a3516df536fbf9a4c11b8
> Author: Lai Jiangshan <laijs@cn.fujitsu.com>
> Date:   Fri Mar 18 11:15:47 2011 +0800
> 
>     rcu: introduce kfree_rcu()
>     
>     Many rcu callbacks functions just call kfree() on the base structure.
>     These functions are trivial, but their size adds up, and furthermore
>     when they are used in a kernel module, that module must invoke the
>     high-latency rcu_barrier() function at module-unload time.
>     
>     The kfree_rcu() function introduced by this commit addresses this issue.
>     Rather than encoding a function address in the embedded rcu_head
>     structure, kfree_rcu() instead encodes the offset of the rcu_head
>     structure within the base structure.  Because the functions are not
>     allowed in the low-order 4096 bytes of kernel virtual memory, offsets
>     up to 4095 bytes can be accommodated.  If the offset is larger than
>     4095 bytes, a compile-time error will be generated in __kfree_rcu().
>     If this error is triggered, you can either fall back to use of call_rcu()
>     or rearrange the structure to position the rcu_head structure into the
>     first 4096 bytes.
>     
>     Note that the allowable offset might decrease in the future, for example,
>     to allow something like kmem_cache_free_rcu().
>     
>     The new kfree_rcu() function can replace code as follows:
>     
>     	call_rcu(&p->rcu, simple_kfree_callback);
>     
>     where "simple_kfree_callback()" might be defined as follows:
>     
>     	void simple_kfree_callback(struct rcu_head *p)
>     	{
>     		struct foo *q = container_of(p, struct foo, rcu);
>     
>     		kfree(q);
>     	}
>     
>     with the following:
>     
>     	kfree_rcu(&p->rcu, rcu);
>     
>     Note that the "rcu" is the name of a field in the structure being
>     freed.  The reason for using this rather than passing in a pointer
>     to the base structure is that the above approach allows better type
>     checking.
>     
>     This commit is based on earlier work by Lai Jiangshan and Manfred Spraul:
>     
>     Lai's V1 patch: http://lkml.org/lkml/2008/9/18/1
>     Manfred's patch: http://lkml.org/lkml/2009/1/2/115
>     
>     Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
>     Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
>     Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Reviewed-and-sneakiness-appreciated-by: David Howells <dhowells@redhat.com>

  reply	other threads:[~2011-04-01 15:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18  4:11 [PATCH 31/36] security,rcu: convert call_rcu(user_update_rcu_disposal) to kfree_rcu() Lai Jiangshan
2011-03-31 18:50 ` David Howells
2011-03-31 18:53   ` David Howells
2011-03-31 19:04   ` Paul E. McKenney
2011-04-01 15:27     ` David Howells [this message]
2011-04-01 15:27 ` David Howells

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=8112.1301671629@redhat.com \
    --to=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@linux-nfs.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    /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