2013-04-22 05:49:29

by Li Guang

[permalink] [raw]
Subject: [PATCH 1/2] smp: use '|=' for csd_lock

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 <[email protected]>
---
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


2013-04-22 05:49:41

by Li Guang

[permalink] [raw]
Subject: [PATCH 2/2] smp: remove 'priv' of call_single_data

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

Signed-off-by: liguang <[email protected]>
---
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

2013-04-22 06:18:42

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

On Mon, Apr 22, 2013 at 7:47 AM, liguang <[email protected]> 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 <[email protected]>
> ---
> 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
>

2013-04-22 06:24:26

by Li Guang

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
> On Mon, Apr 22, 2013 at 7:47 AM, liguang <[email protected]> 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 <[email protected]>
> > ---
> > 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
> >

2013-04-22 06:30:19

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

On Mon, Apr 22, 2013 at 8:22 AM, li guang <[email protected]> wrote:
> 在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
>> On Mon, Apr 22, 2013 at 7:47 AM, liguang <[email protected]> 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 <[email protected]>
>> > ---
>> > 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
>> >
>
>

2013-04-22 06:49:44

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

On Mon, Apr 22, 2013 at 8:30 AM, Sedat Dilek <[email protected]> wrote:
> On Mon, Apr 22, 2013 at 8:22 AM, li guang <[email protected]> wrote:
>> 在 2013-04-22一的 08:18 +0200,Sedat Dilek写道:
>>> On Mon, Apr 22, 2013 at 7:47 AM, liguang <[email protected]> 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 <[email protected]>
>>> > ---
>>> > 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
>>> >
>>
>>

2013-04-23 22:40:22

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

On Mon, 22 Apr 2013 13:47:22 +0800 liguang <[email protected]> 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 <[email protected]>
> ---
> 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 <[email protected]>
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 <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

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
_

2013-04-24 00:11:12

by Li Guang

[permalink] [raw]
Subject: Re: [PATCH 1/2] smp: use '|=' for csd_lock

在 2013-04-23二的 15:40 -0700,Andrew Morton写道:
> On Mon, 22 Apr 2013 13:47:22 +0800 liguang <[email protected]> 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 <[email protected]>
> > ---
> > 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 <[email protected]>
> 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 <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Oleg Nesterov <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Signed-off-by: Andrew Morton <[email protected]>
> ---
>
> 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
> _
>