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: <20201109134139.igx2slqwdhli2jdy@e107158-lin.cambridge.arm.com>
Date:   Mon, 9 Nov 2020 13:41:39 +0000
From:   Qais Yousef <qais.yousef@....com>
To:     Yun Hsiang <hsiang023167@...il.com>
Cc:     Patrick Bellasi <patrick.bellasi@...bug.net>,
        dietmar.eggemann@....com, peterz@...radead.org,
        linux-kernel@...r.kernel.org, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v5 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET
 flag to reset uclamp

On 11/08/20 03:15, Yun Hsiang wrote:
> I think SCHED_FLAG_ALL is for internal kernel use. So I agree with not
> exporting it to user.

+1 for the #ifdef __kernel__

> > > +	if (!(flags & SCHED_FLAG_UTIL_CLAMP_RESET))
> > > +		return false;
> > > +
> > > +	/* Only _UCLAMP_RESET flag set: reset both clamps */
> > > +	if (!(flags & (SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX)))
> > > +		return true;
> > > +
> > > +	/* Both _UCLAMP_RESET and _UCLAMP_MIN flags are set: reset only min */
> > > +	if ((flags & SCHED_FLAG_UTIL_CLAMP_MIN) && clamp_id == UCLAMP_MIN)
> > > +		return true;
> > > +
> > > +	/* Both _UCLAMP_RESET and _UCLAMP_MAX flags are set: reset only max */
> > > +	if ((flags & SCHED_FLAG_UTIL_CLAMP_MAX) && clamp_id == UCLAMP_MAX)
> > > +		return true;
> > > +
> > > +	return false;
> > 
> > I was suggesting maybe we need READ_ONCE() in the if above but did not
> > addressed previous Dietmar's question [2] on why.
> > 
> > The function above has a correct semantics only when the ordering of the
> > if statement is strictly observed.
> > 
> > Now, since we don't have any data dependency on the multiple if cases,
> > are we sure an overzealous compiler will never come up with some
> > "optimized reordering" of the checks required?
> > 
> > IOW, if the compiler could scramble the checks on an optimization, we
> > would get a wrong semantics which is also very difficult do debug.
> > Hence the idea to use READ_ONCE, to both tell the compiler to not
> > even attempt reordering those checks and also to better document the
> > code about the importance of the ordering on those checks.
> > 
> > Is now more clear? Does that makes sense?
> 
> I can undertand what your worries. But I'm not sure is it really needed.
> If there is no other concern I can add it.

I too don't think the compiler has a power to do such an optimization. It must
preserve the order of the checks even if it found a more efficient way to
perform them.

Thanks

--
Qais Yousef

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ