mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] smp: use '|=' for csd_lock
@ 2013-04-22  5:47 liguang
  2013-04-22  5:47 ` [PATCH 2/2] smp: remove 'priv' of call_single_data liguang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: liguang @ 2013-04-22  5:47 UTC (permalink / raw)
  To: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, sedat.dilek, paulmck, linux-kernel
  Cc: liguang

originally, 'data->flags = CSD_FLAG_LOCK',
and we use 'data->flags &= ~CSD_FLAG_LOCK'
for csd_unlock, they are not symmetrix operations
so use '|=' instead of '='.
though, now data->flags only hold CSD_FLAG_LOCK,
it's not so meaningful to use '|=' to set 1 bit,
and '&= ~' to clear 1 bit.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 kernel/smp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index 1818dc0..2d5deb4 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
 static void csd_lock(struct call_single_data *data)
 {
 	csd_lock_wait(data);
-	data->flags = CSD_FLAG_LOCK;
+	data->flags |= CSD_FLAG_LOCK;
 
 	/*
 	 * prevent CPU from reordering the above assignment
-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] smp: remove 'priv' of call_single_data
  2013-04-22  5:47 [PATCH 1/2] smp: use '|=' for csd_lock liguang
@ 2013-04-22  5:47 ` liguang
  2013-04-22  6:18 ` [PATCH 1/2] smp: use '|=' for csd_lock Sedat Dilek
  2013-04-23 22:40 ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: liguang @ 2013-04-22  5:47 UTC (permalink / raw)
  To: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, sedat.dilek, paulmck, linux-kernel
  Cc: liguang

the 'priv' field seems a little redundant,
because we can pass data via 'info'.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 include/linux/smp.h |    1 -
 kernel/softirq.c    |    6 ++----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 3e07a7d..e6564c1 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -20,7 +20,6 @@ struct call_single_data {
 	smp_call_func_t func;
 	void *info;
 	u16 flags;
-	u16 priv;
 };
 
 /* total number of cpus in this system (may exceed NR_CPUS) */
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 14d7758..aa82723 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -620,8 +620,7 @@ static void remote_softirq_receive(void *data)
 	unsigned long flags;
 	int softirq;
 
-	softirq = cp->priv;
-
+	softirq = *(int *)cp->info;
 	local_irq_save(flags);
 	__local_trigger(cp, softirq);
 	local_irq_restore(flags);
@@ -631,9 +630,8 @@ static int __try_remote_softirq(struct call_single_data *cp, int cpu, int softir
 {
 	if (cpu_online(cpu)) {
 		cp->func = remote_softirq_receive;
-		cp->info = cp;
+		cp->info = &softirq;
 		cp->flags = 0;
-		cp->priv = softirq;
 
 		__smp_call_function_single(cpu, cp, 0);
 		return 0;
-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-22  5:47 [PATCH 1/2] smp: use '|=' for csd_lock liguang
  2013-04-22  5:47 ` [PATCH 2/2] smp: remove 'priv' of call_single_data liguang
@ 2013-04-22  6:18 ` Sedat Dilek
  2013-04-22  6:22   ` li guang
  2013-04-23 22:40 ` Andrew Morton
  2 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-04-22  6:18 UTC (permalink / raw)
  To: liguang
  Cc: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, paulmck, linux-kernel

On Mon, Apr 22, 2013 at 7:47 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> originally, 'data->flags = CSD_FLAG_LOCK',
> and we use 'data->flags &= ~CSD_FLAG_LOCK'
> for csd_unlock, they are not symmetrix operations
> so use '|=' instead of '='.
> though, now data->flags only hold CSD_FLAG_LOCK,
> it's not so meaningful to use '|=' to set 1 bit,
> and '&= ~' to clear 1 bit.
>

Hi,

what's the reason I got CCed on this two patches? The ipc-sem-next
issue I reported?

Against what tree are those patches?
They are not compatible with Linux-Next (next-20130419).

Thanks.

Regards,
- Sedat -

[1] http://marc.info/?t=136631457900005&r=1&w=2

> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  kernel/smp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/smp.c b/kernel/smp.c
> index 1818dc0..2d5deb4 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
>  static void csd_lock(struct call_single_data *data)
>  {
>         csd_lock_wait(data);
> -       data->flags = CSD_FLAG_LOCK;
> +       data->flags |= CSD_FLAG_LOCK;
>
>         /*
>          * prevent CPU from reordering the above assignment
> --
> 1.7.2.5
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-22  6:18 ` [PATCH 1/2] smp: use '|=' for csd_lock Sedat Dilek
@ 2013-04-22  6:22   ` li guang
  2013-04-22  6:30     ` Sedat Dilek
  0 siblings, 1 reply; 8+ messages in thread
From: li guang @ 2013-04-22  6:22 UTC (permalink / raw)
  To: sedat.dilek
  Cc: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, paulmck, linux-kernel

在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
> On Mon, Apr 22, 2013 at 7:47 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
> > originally, 'data->flags = CSD_FLAG_LOCK',
> > and we use 'data->flags &= ~CSD_FLAG_LOCK'
> > for csd_unlock, they are not symmetrix operations
> > so use '|=' instead of '='.
> > though, now data->flags only hold CSD_FLAG_LOCK,
> > it's not so meaningful to use '|=' to set 1 bit,
> > and '&= ~' to clear 1 bit.
> >
> 
> Hi,
> 
> what's the reason I got CCed on this two patches? The ipc-sem-next
> issue I reported?

sorry,
just use the result of scripts/get_maintainer.pl

> 
> Against what tree are those patches?
> They are not compatible with Linux-Next (next-20130419).

main

> 
> Thanks.
> 
> Regards,
> - Sedat -
> 
> [1] http://marc.info/?t=136631457900005&r=1&w=2
> 
> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> > ---
> >  kernel/smp.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/kernel/smp.c b/kernel/smp.c
> > index 1818dc0..2d5deb4 100644
> > --- a/kernel/smp.c
> > +++ b/kernel/smp.c
> > @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
> >  static void csd_lock(struct call_single_data *data)
> >  {
> >         csd_lock_wait(data);
> > -       data->flags = CSD_FLAG_LOCK;
> > +       data->flags |= CSD_FLAG_LOCK;
> >
> >         /*
> >          * prevent CPU from reordering the above assignment
> > --
> > 1.7.2.5
> >



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-22  6:22   ` li guang
@ 2013-04-22  6:30     ` Sedat Dilek
  2013-04-22  6:49       ` Sedat Dilek
  0 siblings, 1 reply; 8+ messages in thread
From: Sedat Dilek @ 2013-04-22  6:30 UTC (permalink / raw)
  To: li guang
  Cc: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, paulmck, linux-kernel

On Mon, Apr 22, 2013 at 8:22 AM, li guang <lig.fnst@cn.fujitsu.com> wrote:
> 在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
>> On Mon, Apr 22, 2013 at 7:47 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
>> > originally, 'data->flags = CSD_FLAG_LOCK',
>> > and we use 'data->flags &= ~CSD_FLAG_LOCK'
>> > for csd_unlock, they are not symmetrix operations
>> > so use '|=' instead of '='.
>> > though, now data->flags only hold CSD_FLAG_LOCK,
>> > it's not so meaningful to use '|=' to set 1 bit,
>> > and '&= ~' to clear 1 bit.
>> >
>>
>> Hi,
>>
>> what's the reason I got CCed on this two patches? The ipc-sem-next
>> issue I reported?
>
> sorry,
> just use the result of scripts/get_maintainer.pl
>

Hmm, really this script memyselfandI as a result?

>>
>> Against what tree are those patches?
>> They are not compatible with Linux-Next (next-20130419).
>
> main
>

Andrew renamed data/csd,so it's only 1/2 needing a refresh.
Testing...

Regards,
- Sedat -

>>
>> Thanks.
>>
>> Regards,
>> - Sedat -
>>
>> [1] http://marc.info/?t=136631457900005&r=1&w=2
>>
>> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
>> > ---
>> >  kernel/smp.c |    2 +-
>> >  1 files changed, 1 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/kernel/smp.c b/kernel/smp.c
>> > index 1818dc0..2d5deb4 100644
>> > --- a/kernel/smp.c
>> > +++ b/kernel/smp.c
>> > @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
>> >  static void csd_lock(struct call_single_data *data)
>> >  {
>> >         csd_lock_wait(data);
>> > -       data->flags = CSD_FLAG_LOCK;
>> > +       data->flags |= CSD_FLAG_LOCK;
>> >
>> >         /*
>> >          * prevent CPU from reordering the above assignment
>> > --
>> > 1.7.2.5
>> >
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-22  6:30     ` Sedat Dilek
@ 2013-04-22  6:49       ` Sedat Dilek
  0 siblings, 0 replies; 8+ messages in thread
From: Sedat Dilek @ 2013-04-22  6:49 UTC (permalink / raw)
  To: li guang
  Cc: tglx, peterz, akpm, shli, srivatsa.bhat, suresh.b.siddha,
	fweisbec, paulmck, linux-kernel

On Mon, Apr 22, 2013 at 8:30 AM, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> On Mon, Apr 22, 2013 at 8:22 AM, li guang <lig.fnst@cn.fujitsu.com> wrote:
>> 在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
>>> On Mon, Apr 22, 2013 at 7:47 AM, liguang <lig.fnst@cn.fujitsu.com> wrote:
>>> > originally, 'data->flags = CSD_FLAG_LOCK',
>>> > and we use 'data->flags &= ~CSD_FLAG_LOCK'
>>> > for csd_unlock, they are not symmetrix operations
>>> > so use '|=' instead of '='.
>>> > though, now data->flags only hold CSD_FLAG_LOCK,
>>> > it's not so meaningful to use '|=' to set 1 bit,
>>> > and '&= ~' to clear 1 bit.
>>> >
>>>
>>> Hi,
>>>
>>> what's the reason I got CCed on this two patches? The ipc-sem-next
>>> issue I reported?
>>

NOPE.
( I tried next-20130419 with 3 ipc-sem-next patches plus your two patches. )

- Sedat -

>> sorry,
>> just use the result of scripts/get_maintainer.pl
>>
>
> Hmm, really this script memyselfandI as a result?
>
>>>
>>> Against what tree are those patches?
>>> They are not compatible with Linux-Next (next-20130419).
>>
>> main
>>
>
> Andrew renamed data/csd,so it's only 1/2 needing a refresh.
> Testing...
>
> Regards,
> - Sedat -
>
>>>
>>> Thanks.
>>>
>>> Regards,
>>> - Sedat -
>>>
>>> [1] http://marc.info/?t=136631457900005&r=1&w=2
>>>
>>> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
>>> > ---
>>> >  kernel/smp.c |    2 +-
>>> >  1 files changed, 1 insertions(+), 1 deletions(-)
>>> >
>>> > diff --git a/kernel/smp.c b/kernel/smp.c
>>> > index 1818dc0..2d5deb4 100644
>>> > --- a/kernel/smp.c
>>> > +++ b/kernel/smp.c
>>> > @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
>>> >  static void csd_lock(struct call_single_data *data)
>>> >  {
>>> >         csd_lock_wait(data);
>>> > -       data->flags = CSD_FLAG_LOCK;
>>> > +       data->flags |= CSD_FLAG_LOCK;
>>> >
>>> >         /*
>>> >          * prevent CPU from reordering the above assignment
>>> > --
>>> > 1.7.2.5
>>> >
>>
>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-22  5:47 [PATCH 1/2] smp: use '|=' for csd_lock liguang
  2013-04-22  5:47 ` [PATCH 2/2] smp: remove 'priv' of call_single_data liguang
  2013-04-22  6:18 ` [PATCH 1/2] smp: use '|=' for csd_lock Sedat Dilek
@ 2013-04-23 22:40 ` Andrew Morton
  2013-04-24  0:08   ` li guang
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2013-04-23 22:40 UTC (permalink / raw)
  To: liguang
  Cc: tglx, peterz, shli, srivatsa.bhat, suresh.b.siddha, fweisbec,
	sedat.dilek, paulmck, linux-kernel

On Mon, 22 Apr 2013 13:47:22 +0800 liguang <lig.fnst@cn.fujitsu.com> wrote:

> originally, 'data->flags = CSD_FLAG_LOCK',
> and we use 'data->flags &= ~CSD_FLAG_LOCK'
> for csd_unlock, they are not symmetrix operations
> so use '|=' instead of '='.
> though, now data->flags only hold CSD_FLAG_LOCK,
> it's not so meaningful to use '|=' to set 1 bit,
> and '&= ~' to clear 1 bit.
> 
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> ---
>  kernel/smp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/smp.c b/kernel/smp.c
> index 1818dc0..2d5deb4 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
>  static void csd_lock(struct call_single_data *data)
>  {
>  	csd_lock_wait(data);
> -	data->flags = CSD_FLAG_LOCK;
> +	data->flags |= CSD_FLAG_LOCK;
>  
>  	/*

call_single_data.flags is in fact presently a boolean - we only use one
bit in that word.  We could remove all the &=, |=, & and | operations
on call_single_data.flags and treat it as a boolean.  That would
probably result in faster and smaller code.

But leaving the other 31 bits alone and reserved-for-future-use is not
a bad thing.  But if we're going to do that we should do it consistently.

I rewrote your changelog ;)


From: liguang <lig.fnst@cn.fujitsu.com>
Subject: kernel/smp.c: use '|=' for csd_lock

csd_lock() uses assignment to data->flags rather than |=.  That is not
buggy at present because only one bit (CSD_FLAG_LOCK) is defined in
call_single_data.flags.

But it will become buggy if we later add another flag, so fix it now.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/smp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN kernel/smp.c~kernel-smpc-use-=-for-csd_lock kernel/smp.c
--- a/kernel/smp.c~kernel-smpc-use-=-for-csd_lock
+++ a/kernel/smp.c
@@ -110,7 +110,7 @@ static void csd_lock_wait(struct call_si
 static void csd_lock(struct call_single_data *data)
 {
 	csd_lock_wait(data);
-	data->flags = CSD_FLAG_LOCK;
+	data->flags |= CSD_FLAG_LOCK;
 
 	/*
 	 * prevent CPU from reordering the above assignment
_


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] smp: use '|=' for csd_lock
  2013-04-23 22:40 ` Andrew Morton
@ 2013-04-24  0:08   ` li guang
  0 siblings, 0 replies; 8+ messages in thread
From: li guang @ 2013-04-24  0:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: tglx, peterz, shli, srivatsa.bhat, suresh.b.siddha, fweisbec,
	sedat.dilek, paulmck, linux-kernel

在 2013-04-23二的 15:40 -0700,Andrew Morton写道:
> On Mon, 22 Apr 2013 13:47:22 +0800 liguang <lig.fnst@cn.fujitsu.com> wrote:
> 
> > originally, 'data->flags = CSD_FLAG_LOCK',
> > and we use 'data->flags &= ~CSD_FLAG_LOCK'
> > for csd_unlock, they are not symmetrix operations
> > so use '|=' instead of '='.
> > though, now data->flags only hold CSD_FLAG_LOCK,
> > it's not so meaningful to use '|=' to set 1 bit,
> > and '&= ~' to clear 1 bit.
> > 
> > Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> > ---
> >  kernel/smp.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/kernel/smp.c b/kernel/smp.c
> > index 1818dc0..2d5deb4 100644
> > --- a/kernel/smp.c
> > +++ b/kernel/smp.c
> > @@ -109,7 +109,7 @@ static void csd_lock_wait(struct call_single_data *data)
> >  static void csd_lock(struct call_single_data *data)
> >  {
> >  	csd_lock_wait(data);
> > -	data->flags = CSD_FLAG_LOCK;
> > +	data->flags |= CSD_FLAG_LOCK;
> >  
> >  	/*
> 
> call_single_data.flags is in fact presently a boolean - we only use one
> bit in that word.  We could remove all the &=, |=, & and | operations
> on call_single_data.flags and treat it as a boolean.  That would
> probably result in faster and smaller code.
> 
> But leaving the other 31 bits alone and reserved-for-future-use is not
> a bad thing.  But if we're going to do that we should do it consistently.
> 
> I rewrote your changelog ;)

That's fine, Thanks!

> 
> 
> From: liguang <lig.fnst@cn.fujitsu.com>
> Subject: kernel/smp.c: use '|=' for csd_lock
> 
> csd_lock() uses assignment to data->flags rather than |=.  That is not
> buggy at present because only one bit (CSD_FLAG_LOCK) is defined in
> call_single_data.flags.
> 
> But it will become buggy if we later add another flag, so fix it now.
> 
> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  kernel/smp.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff -puN kernel/smp.c~kernel-smpc-use-=-for-csd_lock kernel/smp.c
> --- a/kernel/smp.c~kernel-smpc-use-=-for-csd_lock
> +++ a/kernel/smp.c
> @@ -110,7 +110,7 @@ static void csd_lock_wait(struct call_si
>  static void csd_lock(struct call_single_data *data)
>  {
>  	csd_lock_wait(data);
> -	data->flags = CSD_FLAG_LOCK;
> +	data->flags |= CSD_FLAG_LOCK;
>  
>  	/*
>  	 * prevent CPU from reordering the above assignment
> _
> 



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-04-24  0:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-22  5:47 [PATCH 1/2] smp: use '|=' for csd_lock liguang
2013-04-22  5:47 ` [PATCH 2/2] smp: remove 'priv' of call_single_data liguang
2013-04-22  6:18 ` [PATCH 1/2] smp: use '|=' for csd_lock Sedat Dilek
2013-04-22  6:22   ` li guang
2013-04-22  6:30     ` Sedat Dilek
2013-04-22  6:49       ` Sedat Dilek
2013-04-23 22:40 ` Andrew Morton
2013-04-24  0:08   ` li guang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®