Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4679435rwd; Tue, 30 May 2023 08:27:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62BErtAFs2egJ4LWoEdHieF3HgFHCarKgZZiesRerOKnhvRf2Hyq3QW47CosVX1a6B6qbP X-Received: by 2002:a05:6a00:138b:b0:643:9ca:3c7d with SMTP id t11-20020a056a00138b00b0064309ca3c7dmr3636105pfg.4.1685460440335; Tue, 30 May 2023 08:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685460440; cv=none; d=google.com; s=arc-20160816; b=wDLAf3M+VmRnpU3z50/ELnUlxcDAmBS2oA1tVU7fpqQb4+rlwVyb90Jnqi0zPTedF+ UMQoKW2S13iFxbMaPA8kwQY7nxKb7Rq452bRthL6fwgwfZqVPHj7sBvYKIQWESz7imXu mxyQxWt6R2meQLVRyaLHSEyfo3Oh3nG8XcOLVh1YSdBVSz0cVKxy9pqbat2uFzKbnj7M XBX4EIo42UwmLMf2z+OuJhss1y0HZrqU2HjdwEsaK6ujDynT3eooiY+QifnSTkzvbA65 V7BhyvrCfQ6D6p94/8vV/yHBHALjQvFMvX4NzReJ8B0v8Ox6cZizDpmG6DgqiO4JboAS 9yBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=6I0l7pg/D2lUCk/n2Oxb30xTJNpx8Adf4I+RsmuUvok=; b=JVIsc7Ac6FFRsNIbwp+XWfI+cZJRkmHj8ScUBULFkiV78FAH8tmzN0LTeujkO06nCO 54Sk861iMf43mXLMQiImdasouIOnQj5KkBqNgNE2HQlkBJtxZbgAyV881PEouIxUUTee /z/xky7cpVkk6HQLJlDsRFqO2bG3lvcVgsdshq6MgOZ888Z4JnZdn4yoHhCLnMGV1R3Y 88yqCqboHCjREtNakyBt+fk8BIPUhncblkvzzW9HGlIC1N4RFDp319mRDom6oyHg8erF /r4cC278KN5w295GHQxEOSKLVJsuU9GIVYER83Fl+6pr8zuHsY7960gvdcSPy9xm6ANF LIbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=jm09fyBF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 194-20020a6218cb000000b0064d2b749b3csi1881687pfy.71.2023.05.30.08.27.06; Tue, 30 May 2023 08:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=jm09fyBF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbjE3PNk (ORCPT + 99 others); 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 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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