All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shan Wei <shanwei88@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: jesse@nicira.com, dev@openvswitch.org,
	NetDev <netdev@vger.kernel.org>,
	Kernel-Maillist <linux-kernel@vger.kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
Date: Thu, 01 Nov 2012 18:07:03 +0800	[thread overview]
Message-ID: <509249C7.3080000@gmail.com> (raw)
In-Reply-To: <0000013ab7e86f8a-4adb8b81-19be-4264-96f1-924aaf3819f2-000000@email.amazonses.com>

Christoph Lameter said, at 2012/11/1 1:39:
> On Wed, 31 Oct 2012, Shan Wei wrote:
> 
>> --- a/net/openvswitch/datapath.c
>> +++ b/net/openvswitch/datapath.c
>> @@ -208,7 +208,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
>>  	int error;
>>  	int key_len;
>>
>> -	stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
>> +	stats = this_cpu_ptr(dp->stats_percpu);
> 
> Well this is an improvement and may be ok if the preemption is disabled at
> this point. There is another possibility here to use this_cpu_read/add/inc
> instead of determining the pointer to the local cpu first and then
> performing operations on the fields. The pointer relocation with
> this_cpu_xxx ops is implicit in the instructions and safe against changing
> of processors. It would also save us the determination of a pointer to the
> current cpus stats structure.

yes, this_cpu_ptr just locate the point to current cpu per-cpu data domain.
and then operating [read/write/inc/sub] fields of this per-cpu variable
maybe on other cpu because task is rescheduled for preemption, interrupt.

But for different field in same per-cpu variable, how to guarantee n_missed
and n_hit are from same cpu? 
this_cpu_read(dp->stats_percpu->n_missed);
[processor changed]
this_cpu_read(dp->stats_percpu->n_hit);


In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.

cpu=get_cpu()
....
*per_cpu_ptr(p,cpu)
....
....
put_cpu()


  reply	other threads:[~2012-11-01 10:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 11:22 [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper Shan Wei
2012-10-31 17:39 ` Christoph Lameter
2012-11-01 10:07   ` Shan Wei [this message]
2012-11-01 14:33     ` Christoph Lameter
2012-11-02  1:38       ` Jesse Gross
2012-11-02 14:01         ` Christoph Lameter
  -- strict thread matches above, loose matches on Subject: below --
2012-11-02 16:01 Shan Wei
2012-11-02 17:46 ` Christoph Lameter
2012-11-08 14:22   ` Shan Wei
2012-11-08 17:18     ` Christoph Lameter
2012-11-09  1:39       ` Shan Wei

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=509249C7.3080000@gmail.com \
    --to=shanwei88@gmail.com \
    --cc=cl@linux.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=jesse@nicira.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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.