diff mbox

[RESEND] ARM: sched: correct update_sched_clock()

Message ID 1360128076-8555-1-git-send-email-iamjoonsoo.kim@lge.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joonsoo Kim Feb. 6, 2013, 5:21 a.m. UTC
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>

Comments

Linus Walleij Feb. 6, 2013, 9:33 a.m. UTC | #1
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
Joonsoo Kim Feb. 6, 2013, 3:08 p.m. UTC | #2
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.
Russell King - ARM Linux Feb. 6, 2013, 4:33 p.m. UTC | #3
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.
Joonsoo Kim Feb. 8, 2013, 6:51 a.m. UTC | #4
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/
Russell King - ARM Linux Feb. 8, 2013, 3:03 p.m. UTC | #5
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?
Nicolas Pitre Feb. 8, 2013, 6:40 p.m. UTC | #6
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
Joonsoo Kim Feb. 9, 2013, 4:57 a.m. UTC | #7
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/
diff mbox

Patch

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);
 }