linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Zhou Yanjie <zhouyanjie@wanyeetech.com>,
	od@zcrc.me, linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v4 1/2] sched: Add sched_clock_register_new()
Date: Tue, 11 Feb 2020 10:31:13 -0300	[thread overview]
Message-ID: <1581427873.3.0@crapouillou.net> (raw)
In-Reply-To: <87lfp94duq.fsf@nanos.tec.linutronix.de>

Hi Thomas,


Le mar., févr. 11, 2020 at 11:28, Thomas Gleixner <tglx@linutronix.de> 
a écrit :
> Paul!
> 
> Paul Cercueil <paul@crapouillou.net> writes:
> 
>>  The sched_clock_register_new() behaves like sched_clock_register() 
>> but
> 
> This function name does not make any sense. Two years from now you are
> going to provide sched_clock_register_new_2_dot_0() ?

I'm open to suggestions :)
The point of using a different function was to avoid a huge patchset to 
fix the 50+ drivers that use sched_clock_register().

>>  takes an extra parameter which is passed to the read callback.
> 
> This lacks any form of justification why this function and the data
> pointer is required.
> 
>>    * @sched_clock_mask:   Bitmask for two's complement subtraction 
>> of non 64bit
>>    *			clocks.
>>    * @read_sched_clock:	Current clock source (or dummy source when 
>> suspended).
>>  + * @data:		Callback data for the current clock source.
>>    * @mult:		Multipler for scaled math conversion.
>>    * @shift:		Shift value for scaled math conversion.
>>    *
>>  @@ -39,7 +40,8 @@ struct clock_read_data {
>>   	u64 epoch_ns;
>>   	u64 epoch_cyc;
>>   	u64 sched_clock_mask;
>>  -	u64 (*read_sched_clock)(void);
>>  +	u64 (*read_sched_clock)(void *);
> 
> How is that supposed to work without fixing up _all_ sched clock
> instances? So the below typecast
> 
>>  +void __init
>>  +sched_clock_register(u64 (*read)(void), int bits, unsigned long 
>> rate)
>>  +{
>>  +	sched_clock_register_new((u64 (*)(void *))read, bits, rate, NULL);
> 
> makes it compile.
> 
> By pure luck this does not explode in your face at runtime when the
> existing read(void) functions are called with an argument. Any stack
> based argument passing calling convention would fall flat on it's 
> nose.
> 
> While clever this is really an ugly hack.

Alright, I really didn't think it was that bad. Next time I'll use a 
wrapper.

> As the clocksource for which you are doing this is a single instance,
> what's wrong with having some static storage for the information you
> need as any other driver which has the same problem does as well?

The fact that every other driver with the same problem decides to add a 
workaround instead of a proper fix does not mean that the problem does 
not exist.

> If there is really a point in avoiding a few bytes of static storage,
> then this needs to be cleaned up treewide and not hacked around.

My allergy of static storage is not worth the trouble of a treewide 
pathset so I'll just drop this patch and send a v5.

Thanks,
-Paul




      reply	other threads:[~2020-02-11 13:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 13:42 [PATCH v4 1/2] sched: Add sched_clock_register_new() Paul Cercueil
2020-02-10 13:42 ` [PATCH v4 2/2] clocksource: Add driver for the Ingenic JZ47xx OST Paul Cercueil
2020-02-11 10:28 ` [PATCH v4 1/2] sched: Add sched_clock_register_new() Thomas Gleixner
2020-02-11 13:31   ` Paul Cercueil [this message]

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=1581427873.3.0@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=od@zcrc.me \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=zhouyanjie@wanyeetech.com \
    /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 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).