From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 9A1B23858D28 for ; Tue, 30 May 2023 15:13:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A1B23858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1685459617; bh=hsFGav/0/u3lTU7+URVYstvkYkxZoD/CB/dNCylhnns=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=jm09fyBFvoCjveRnyfPnPAfPVbw6ZrQ0spA2iCWttSjGgkA8lPneETJ5r3u7synjR Wbp4x4LeMkk/+5wReXgE694Car5yilZcGdEBBf6q06jZo1AUorAuwJMo31VL84YqhE KfNOhfN9c2mTC6gSPLFw8/CwAObJDGnK4keYjV7B+vsGnMuKp3Xoy79HRCfzzjGK0p tme9osxoaoXXL9As8oCVQlj2ZmUqbvvB186PAzKo40AsYXtI4d+wtQXltFNwHEOx/h RZO6+UgR0WMZ4L35RSdeCmd/wDeL2CkJW9RkJQ3Cp6IAOcPdwYvCwk9Q4er/30sdD7 5NFk936bpdwsQ== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QVwrw4h3pz16Q3; Tue, 30 May 2023 11:13:36 -0400 (EDT) Message-ID: Date: Tue, 30 May 2023 11:13:41 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [RFC PATCH v2 1/4] rseq: Add sched_state field to struct rseq Content-Language: en-US From: Mathieu Desnoyers To: Florian Weimer Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Ingo Molnar , Darren Hart , Davidlohr Bueso , =?UTF-8?Q?Andr=c3=a9_Almeida?= , libc-alpha@sourceware.org, Steven Rostedt , Jonathan Corbet , Noah Goldstein , longman@redhat.com, Olivier Dion References: <20230529191416.53955-1-mathieu.desnoyers@efficios.com> <20230529191416.53955-2-mathieu.desnoyers@efficios.com> <87wn0r6id9.fsf@oldenburg.str.redhat.com> <2c421e36-a749-7dc3-3562-7a8cf256df3c@efficios.com> <87sfbew7ra.fsf@oldenburg.str.redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 5/30/23 10:25, Mathieu Desnoyers wrote: > On 5/30/23 04:20, Florian Weimer wrote: [...] >> >> The challenge is that once we put stuff at fixed offsets, we can't >> transparently fix it later.  It would need more auxv entries with >> further offsets, or accessing this data through some indirection, >> perhaps via vDSO helpers. > > Perhaps this is more flexibility/complexity than we really need. One > possible approach would be to split struct rseq into sub-structures, e.g.: > > rseq_len = overall size of all sub-structures. > auxv AT_RSEQ_ALIGN = 256 > > auxv AT_RSEQ_FEATURE_SIZE = size of first portion of struct rseq, >                             at most 256 bytes, meant to contain fields >                             stored/loaded from the thread doing the >                             registration. > auxv AT_RSEQ_SHARED_FEATURE_SIZE = >                             size of 2nd portion of struct rseq, >                             starts at offset 256, at most 256 bytes, >                             meant to contain fields stored/loaded by >                             any thread. > > Then we have this layout: > > struct rseq { >   struct rseq_local { >     /* Fields accessed from local thread. */ > >   } __attribute__((aligned((256)); >   struct rseq_shared { >     /* Shared fields. */ > >   } __attribute__((aligned(256)); > } __attribute__((aligned(256)); > > And if someday AT_RSEQ_FEATURE_SIZE needs to grow over 256 bytes > (32 * u64), we can still extend with a new auxv entry after the "shared" > features. Actually, after giving it some more thoughts, I think we can do better: - Add a sys_rseq() rseq_flag RSEQ_FLAG_SHARED, which changes the behavior of sys_rseq() to expect an additional "struct rseq_shared *" argument. - Introduce auxv AT_RSEQ_SHARED_FEATURE_SIZE. This way, it's up to the libc to decide how to allocate its private vs shared rseq structures. The auxv "AT_RSEQ_ALIGN" would dictate the minimal alignment required for both private and shared rseq structures. I don't think we need to express the size of the rseq_shared memory area allocated by libc because we know that it needs to be large enough to handle the shared feature size. Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com