linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] ARM: sched: correct update_sched_clock()
@ 2013-02-06  5:21 Joonsoo Kim
  2013-02-06  9:33 ` Linus Walleij
  0 siblings, 1 reply; 8+ messages in thread
From: Joonsoo Kim @ 2013-02-06  5:21 UTC (permalink / raw)
  To: Russell King
  Cc: linux-arm-kernel, linux-kernel, js1304, Linus Walleij, Joonsoo Kim

If we want load epoch_cyc and epoch_ns atomically,
we should update epoch_cyc_copy first of all.
This notify reader that updating is in progress.

If we update epoch_cyc first like as current implementation,
there is subtle error case.
Look at the below example.

<Initial Condition>
cyc = 9
ns = 900
cyc_copy = 9

== CASE 1 ==
<CPU A = reader>           <CPU B = updater>
                           write cyc = 10
read cyc = 10
read ns = 900
                           write ns = 1000
                           write cyc_copy = 10
read cyc_copy = 10

output = (10, 900)

== CASE 2 ==
<CPU A = reader>           <CPU B = updater>
read cyc = 9
                           write cyc = 10
                           write ns = 1000
read ns = 1000
read cyc_copy = 9
                           write cyc_copy = 10
output = (9, 1000)

If atomic read is ensured, output should be (9, 900) or (10, 1000).
But, output in example case are not.

So, change updating sequence in order to correct this problem.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

diff --git a/arch/arm/kernel/sched_clock.c b/arch/arm/kernel/sched_clock.c
index fc6692e..bd6f56b 100644
--- a/arch/arm/kernel/sched_clock.c
+++ b/arch/arm/kernel/sched_clock.c
@@ -93,11 +93,11 @@ static void notrace update_sched_clock(void)
 	 * detectable in cyc_to_fixed_sched_clock().
 	 */
 	raw_local_irq_save(flags);
-	cd.epoch_cyc = cyc;
+	cd.epoch_cyc_copy = cyc;
 	smp_wmb();
 	cd.epoch_ns = ns;
 	smp_wmb();
-	cd.epoch_cyc_copy = cyc;
+	cd.epoch_cyc = cyc;
 	raw_local_irq_restore(flags);
 }
 
-- 
1.7.9.5


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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-06  5:21 [PATCH RESEND] ARM: sched: correct update_sched_clock() Joonsoo Kim
@ 2013-02-06  9:33 ` Linus Walleij
  2013-02-06 15:08   ` JoonSoo Kim
  2013-02-06 16:33   ` Russell King - ARM Linux
  0 siblings, 2 replies; 8+ messages in thread
From: Linus Walleij @ 2013-02-06  9:33 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Russell King, linux-arm-kernel, linux-kernel, js1304

On Wed, Feb 6, 2013 at 6:21 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:

> If we want load epoch_cyc and epoch_ns atomically,
> we should update epoch_cyc_copy first of all.
> This notify reader that updating is in progress.

If you think the patch is finished, put it into Russell's patch tracker:
http://www.arm.linux.org.uk/developer/patches/

Yours,
Linus Walleij

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-06  9:33 ` Linus Walleij
@ 2013-02-06 15:08   ` JoonSoo Kim
  2013-02-06 16:33   ` Russell King - ARM Linux
  1 sibling, 0 replies; 8+ messages in thread
From: JoonSoo Kim @ 2013-02-06 15:08 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Joonsoo Kim, Russell King, linux-arm-kernel, linux-kernel

Hello, Linus.

2013/2/6 Linus Walleij <linus.walleij@linaro.org>:
> On Wed, Feb 6, 2013 at 6:21 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
>
>> If we want load epoch_cyc and epoch_ns atomically,
>> we should update epoch_cyc_copy first of all.
>> This notify reader that updating is in progress.
>
> If you think the patch is finished, put it into Russell's patch tracker:
> http://www.arm.linux.org.uk/developer/patches/

Ah... Okay.
Thanks for notifying me.

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-06  9:33 ` Linus Walleij
  2013-02-06 15:08   ` JoonSoo Kim
@ 2013-02-06 16:33   ` Russell King - ARM Linux
  2013-02-08  6:51     ` Joonsoo Kim
  1 sibling, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2013-02-06 16:33 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Joonsoo Kim, linux-arm-kernel, linux-kernel, js1304

On Wed, Feb 06, 2013 at 10:33:53AM +0100, Linus Walleij wrote:
> On Wed, Feb 6, 2013 at 6:21 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> 
> > If we want load epoch_cyc and epoch_ns atomically,
> > we should update epoch_cyc_copy first of all.
> > This notify reader that updating is in progress.
> 
> If you think the patch is finished, put it into Russell's patch tracker:
> http://www.arm.linux.org.uk/developer/patches/

Yea, this patch looks like the right thing... and yes, into the patch
system please.

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-06 16:33   ` Russell King - ARM Linux
@ 2013-02-08  6:51     ` Joonsoo Kim
  2013-02-08 15:03       ` Russell King - ARM Linux
  0 siblings, 1 reply; 8+ messages in thread
From: Joonsoo Kim @ 2013-02-08  6:51 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: Linus Walleij, linux-arm-kernel, linux-kernel

Hello, Russell.

On Wed, Feb 06, 2013 at 04:33:55PM +0000, Russell King - ARM Linux wrote:
> On Wed, Feb 06, 2013 at 10:33:53AM +0100, Linus Walleij wrote:
> > On Wed, Feb 6, 2013 at 6:21 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > 
> > > If we want load epoch_cyc and epoch_ns atomically,
> > > we should update epoch_cyc_copy first of all.
> > > This notify reader that updating is in progress.
> > 
> > If you think the patch is finished, put it into Russell's patch tracker:
> > http://www.arm.linux.org.uk/developer/patches/
> 
> Yea, this patch looks like the right thing... and yes, into the patch
> system please.

I try to put it into patch tracker, but I fail to put it.
I use following command.

git send-email --to patches@arm.linux.org.uk 0001-ARM-sched-correct~~~~~

Am I wrong?
Could you teach me how to put patch into your patch tracker?
I already read "help" on your website, but I can't find any stuff for
"git send-email".

Thanks.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-08  6:51     ` Joonsoo Kim
@ 2013-02-08 15:03       ` Russell King - ARM Linux
  2013-02-08 18:40         ` Nicolas Pitre
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2013-02-08 15:03 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Linus Walleij, linux-arm-kernel, linux-kernel

On Fri, Feb 08, 2013 at 03:51:25PM +0900, Joonsoo Kim wrote:
> I try to put it into patch tracker, but I fail to put it.
> I use following command.
> 
> git send-email --to patches@arm.linux.org.uk 0001-ARM-sched-correct~~~~~
> 
> Am I wrong?
> Could you teach me how to put patch into your patch tracker?
> I already read "help" on your website, but I can't find any stuff for
> "git send-email".

I've never used git to send email, so I'm afraid I can't help with that.
Maybe someone with more experience with sending email from git can
comment?

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-08 15:03       ` Russell King - ARM Linux
@ 2013-02-08 18:40         ` Nicolas Pitre
  2013-02-09  4:57           ` JoonSoo Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Pitre @ 2013-02-08 18:40 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Joonsoo Kim, Linus Walleij, linux-arm-kernel, linux-kernel

On Fri, 8 Feb 2013, Russell King - ARM Linux wrote:

> On Fri, Feb 08, 2013 at 03:51:25PM +0900, Joonsoo Kim wrote:
> > I try to put it into patch tracker, but I fail to put it.
> > I use following command.
> > 
> > git send-email --to patches@arm.linux.org.uk 0001-ARM-sched-correct~~~~~
> > 
> > Am I wrong?
> > Could you teach me how to put patch into your patch tracker?
> > I already read "help" on your website, but I can't find any stuff for
> > "git send-email".
> 
> I've never used git to send email, so I'm afraid I can't help with that.
> Maybe someone with more experience with sending email from git can
> comment?

The commit text for the patch needs to contain the following 2 lines at 
the very bottom in order to match the patch system's expectations:

PATCH FOLLOWS
KernelVersion: v3.8

The KernelVersion value needs to be adjusted of course.

Note: I never tried it myself but it ought to work.

Nicolas

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

* Re: [PATCH RESEND] ARM: sched: correct update_sched_clock()
  2013-02-08 18:40         ` Nicolas Pitre
@ 2013-02-09  4:57           ` JoonSoo Kim
  0 siblings, 0 replies; 8+ messages in thread
From: JoonSoo Kim @ 2013-02-09  4:57 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: Russell King - ARM Linux, Joonsoo Kim, Linus Walleij,
	linux-arm-kernel, linux-kernel

2013/2/9 Nicolas Pitre <nicolas.pitre@linaro.org>:
> On Fri, 8 Feb 2013, Russell King - ARM Linux wrote:
>
>> On Fri, Feb 08, 2013 at 03:51:25PM +0900, Joonsoo Kim wrote:
>> > I try to put it into patch tracker, but I fail to put it.
>> > I use following command.
>> >
>> > git send-email --to patches@arm.linux.org.uk 0001-ARM-sched-correct~~~~~
>> >
>> > Am I wrong?
>> > Could you teach me how to put patch into your patch tracker?
>> > I already read "help" on your website, but I can't find any stuff for
>> > "git send-email".
>>
>> I've never used git to send email, so I'm afraid I can't help with that.
>> Maybe someone with more experience with sending email from git can
>> comment?
>
> The commit text for the patch needs to contain the following 2 lines at
> the very bottom in order to match the patch system's expectations:
>
> PATCH FOLLOWS
> KernelVersion: v3.8
>
> The KernelVersion value needs to be adjusted of course.
>
> Note: I never tried it myself but it ought to work.

Yes!!!! It works!
Thanks!!!

> Nicolas
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2013-02-09  4:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  5:21 [PATCH RESEND] ARM: sched: correct update_sched_clock() Joonsoo Kim
2013-02-06  9:33 ` Linus Walleij
2013-02-06 15:08   ` JoonSoo Kim
2013-02-06 16:33   ` Russell King - ARM Linux
2013-02-08  6:51     ` Joonsoo Kim
2013-02-08 15:03       ` Russell King - ARM Linux
2013-02-08 18:40         ` Nicolas Pitre
2013-02-09  4:57           ` JoonSoo Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).