mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Paul Cercueil <paul@crapouillou.net>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: 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 11:28:45 +0100	[thread overview]
Message-ID: <87lfp94duq.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20200210134213.8324-1-paul@crapouillou.net>

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() ?

> 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.

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?

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.

Thanks,

        tglx




  parent reply	other threads:[~2020-02-11 10:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 13:42 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 ` Thomas Gleixner [this message]
2020-02-11 13:31   ` [PATCH v4 1/2] sched: Add sched_clock_register_new() Paul Cercueil

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=87lfp94duq.fsf@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=od@zcrc.me \
    --cc=paul@crapouillou.net \
    --cc=peterz@infradead.org \
    --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

all inboxes | Powered by JetHome®