[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221007203425.GA5647@ranerica-svr.sc.intel.com>
Date: Fri, 7 Oct 2022 13:34:25 -0700
From: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Ricardo Neri <ricardo.neri@...el.com>,
"Ravi V. Shankar" <ravi.v.shankar@...el.com>,
Ben Segall <bsegall@...gle.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Len Brown <len.brown@...el.com>, Mel Gorman <mgorman@...e.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Steven Rostedt <rostedt@...dmis.org>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Valentin Schneider <vschneid@...hat.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, "Tim C . Chen" <tim.c.chen@...el.com>
Subject: Re: [RFC PATCH 14/23] thermal: intel: hfi: Update the class of the
current task
On Tue, Sep 27, 2022 at 01:46:59PM +0200, Peter Zijlstra wrote:
> On Fri, Sep 09, 2022 at 04:11:56PM -0700, Ricardo Neri wrote:
> > +union hfi_thread_feedback_char_msr {
> > + struct {
> > + u8 classid;
> > + u64 __reserved:55;
> > + u8 valid:1;
> > + } split;
> > + u64 full;
> > +};
>
> Urgh, did you perhaps mean:
>
> struct {
> u64 classid :8;
> u64 __reserved :55;
> u64 valid :1
> };
>
> ?
>
> Because yes, GCC does fold that into a single u64, but that's
> implementation defined behaviour; the C spec doesn't require one to pack
> adjacent bitfields of different types together.
>
> I layout of:
>
> u8 class; // offset 0
> u64 __reserver : 55; // offset 8
> u8 valid : 1; // offset 16
>
> with a total size of 24 bytes is, AFAIU, a valid result of what you
> wrote.
I checked the C99 and C11 specs and, IIUC, it does prescribe how to handle
adjacent bit-fields:
"An implementation may allocate any addressable storage unit large
enough to hold a bitfield. If enough space remains, a bit-field
that immediately follows another bit-field in a structure shall be
packed into adjacent bits of the same unit."
Hence, __reserved and valid should be packed. classid, however, it is not
guaranteed to be adjacent to __reserved.
I will implement the struct are you have described.
Thanks and BR,
Ricardo
Powered by blists - more mailing lists