public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
Cc: "Eric Dumazet" <dada1@cosmosbay.com>,
	"Andrew Morton" <akpm@osdl.org>, "Greg KH" <gregkh@suse.de>,
	"Arjan" <arjan@linux.intel.com>,
	"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: Re: kref refcnt and false positives
Date: Thu, 14 Dec 2006 17:19:55 -0700	[thread overview]
Message-ID: <m13b7ivwlw.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <EB12A50964762B4D8111D55B764A8454010572C1@scsmsx413.amr.corp.intel.com> (Venkatesh Pallipadi's message of "Thu, 14 Dec 2006 15:51:38 -0800")

"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> writes:

>>But I believe Venkatesh problem comes from its release() 
>>function : It is 
>>supposed to free the object.
>>If not, it should properly setup it so that further uses are OK.
>>
>>ie doing in release(kref)
>>atomic_set(&kref->count, 0);
>>
>
> Agreed that setting kref refcnt to 0 in release will solve the probloem.
> But, once the optimization code is removed, we don't need to set it to
> zero as release will only be called after the count reaches zero anyway.

The primary point of the optimization is to not write allocate a cache line
unnecessarily.   I don't know it's value, but it can have one especially
on big way SMP machines.

If the optimization is not performed setting the value to 0 immediately
there after has not real cost as your cpu has the dirty cache line
already.  If the optimization is performed you still have to dirty
the cache line but at least you don't have to allocate it.

How that compares to the branch mispredict in cost I don't know, except
that cache line misses are the only operation that is generally
more expensive than branch misses.

So I see no virtue in avoiding the atomic_set(&kref->count, 0) if
you are about to immediately reuse the data structure.

Eric

  reply	other threads:[~2006-12-15  0:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-14 23:51 kref refcnt and false positives Pallipadi, Venkatesh
2006-12-15  0:19 ` Eric W. Biederman [this message]
2006-12-15  0:35   ` Andrew Morton
2006-12-15  0:53     ` Eric W. Biederman
     [not found] <200612210901.kBL91MwR027509@hera.kernel.org>
2006-12-31 15:16 ` David Woodhouse
2007-01-01 20:13   ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2006-12-13 23:34 Venkatesh Pallipadi
2006-12-14  0:12 ` Greg KH
2006-12-14  0:08   ` Venkatesh Pallipadi
2006-12-14  0:41   ` Andrew Morton
2006-12-14  7:56     ` Eric Dumazet

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=m13b7ivwlw.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=arjan@linux.intel.com \
    --cc=dada1@cosmosbay.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=venkatesh.pallipadi@intel.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