lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87wmvl61i1.ffs@tglx>
Date:   Tue, 17 Oct 2023 11:29:10 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     lakshmi.sowjanya.d@...el.com, jstultz@...gle.com,
        giometti@...eenne.com, corbet@....net, linux-kernel@...r.kernel.org
Cc:     x86@...nel.org, linux-doc@...r.kernel.org,
        andriy.shevchenko@...ux.intel.com, eddie.dong@...el.com,
        christopher.s.hall@...el.com, pandith.n@...el.com,
        mallikarjunappa.sangannavar@...el.com, thejesh.reddy.t.r@...el.com,
        lakshmi.sowjanya.d@...el.com
Subject: Re: [PATCH v1 2/6] x86/tsc: Convert Time Stamp Counter (TSC) value
 to Always Running Timer (ART)

On Tue, Oct 17 2023 at 10:54, lakshmi.sowjanya.d@...el.com wrote:
>  
> +/*
> + * Converts input TSC to the corresponding ART value using conversion
> + * factors discovered by detect_art().
> + *
> + * Return: 0 on success, -errno on failure.

bool indicating success / fail ?

> + */
> +int convert_tsc_to_art(const struct system_counterval_t *system_counter,
> +		       u64 *art)
> +{
> +	u64 tmp, res, rem;
> +	/* ART = TSC * tsc_to_art_denominator / tsc_to_art_numerator */
> +	struct u32_fract tsc_to_art = {
> +		.numerator = art_to_tsc_denominator,
> +		.denominator = art_to_tsc_numerator,
> +	};

The purpose of this struct is to obfuscate the code, right?

The struct would make sense if a pointer would be handed to some other
function.

> +	if (system_counter->cs != art_related_clocksource)
> +		return -EINVAL;
> +
> +	res = system_counter->cycles - art_to_tsc_offset;
> +	rem = do_div(res, tsc_to_art.denominator);
> +
> +	tmp = rem * tsc_to_art.numerator;
> +	do_div(tmp, tsc_to_art.denominator);
> +	*art = res * tsc_to_art.numerator + tmp;

Yet another copy of the math in convert_art_to_tsc() and in
convert_art_ns_to_tsc(). Seriously?

Can we please have _one_ helper function which takes value, nominator,
denominator as arguments and clean up the copy&pasta instead of adding
more?

Thanks,

        tglx










Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ