From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED5A3C77B7A for ; Tue, 30 May 2023 15:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231714AbjE3PNk (ORCPT ); Tue, 30 May 2023 11:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230404AbjE3PNj (ORCPT ); Tue, 30 May 2023 11:13:39 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EF9C5; Tue, 30 May 2023 08:13:37 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org 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