diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-02-07 12:15:10 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-02-07 12:15:10 -0800 |
commit | 6270aa63b3ee5dcf78aa915719a0425bbee176ee (patch) | |
tree | a1dc773f8ec9fd1bc7954f46337c5c6c8f2a8f6e /driver | |
parent | 641e80f1e8bdbcc54e037795ab9bbfc072551500 (diff) | |
download | patches-6270aa63b3ee5dcf78aa915719a0425bbee176ee.tar.gz |
pci patches
Diffstat (limited to 'driver')
-rw-r--r-- | driver/kref-avoid-an-atomic-operation-in-kref_put.patch | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/driver/kref-avoid-an-atomic-operation-in-kref_put.patch b/driver/kref-avoid-an-atomic-operation-in-kref_put.patch new file mode 100644 index 0000000000000..919101fe879a9 --- /dev/null +++ b/driver/kref-avoid-an-atomic-operation-in-kref_put.patch @@ -0,0 +1,36 @@ +From linux-kernel-owner+greg=40kroah.com-S1751243AbWA3FTq@vger.kernel.org Sun Jan 29 21:20:33 2006 +Message-ID: <43DDA1E7.5010109@cosmosbay.com> +Date: Mon, 30 Jan 2006 06:19:35 +0100 +From: Eric Dumazet <dada1@cosmosbay.com> +To: Greg KH <greg@kroah.com> +Cc: "Eric W. Biederman" <ebiederm@xmission.com>, Herbert Poetzl <herbert@13thfloor.at>, "Serge E. Hallyn" <serue@us.ibm.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>, Dave Hansen <haveblue@us.ibm.com>, Arjan van de Ven <arjan@infradead.org>, Suleiman Souhlal <ssouhlal@FreeBSD.org>, Hubertus Franke <frankeh@watson.ibm.com>, Cedric Le Goater <clg@fr.ibm.com>, Kyle Moffett <mrmacman_g4@mac.com> +Subject: kref: avoid an atomic operation in kref_put() + +Avoid an atomic operation in kref_put() when the last reference is +dropped. On most platforms, atomic_read() is a plan read of the counter +and involves no atomic at all. + + +Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + lib/kref.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- gregkh-2.6.orig/lib/kref.c ++++ gregkh-2.6/lib/kref.c +@@ -52,7 +52,12 @@ int kref_put(struct kref *kref, void (*r + WARN_ON(release == NULL); + WARN_ON(release == (void (*)(struct kref *))kfree); + +- if (atomic_dec_and_test(&kref->refcount)) { ++ /* ++ * if current count is one, we are the last user and can release object ++ * right now, avoiding an atomic operation on 'refcount' ++ */ ++ if ((atomic_read(&kref->refcount) == 1) || ++ (atomic_dec_and_test(&kref->refcount))) { + release(kref); + return 1; + } |