Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1947013iob; Sun, 15 May 2022 03:35:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHwclnaw93L03gnj0C9ZHb+V/0HlQdymQhH8SOD9fcKz/j8Ncplaz8hvcShkX+Hk1MNXaN X-Received: by 2002:a05:600c:3792:b0:394:5fa4:f2a4 with SMTP id o18-20020a05600c379200b003945fa4f2a4mr12547616wmr.33.1652610903875; Sun, 15 May 2022 03:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652610903; cv=none; d=google.com; s=arc-20160816; b=TarvB3VwTclp4KRfWu6Wjuj72CeFG+Qz8iGD8G1dMF+GYJ46Fq6L2QaeUMmCIV/IXe STcV/tDS6EHRGQQ4pkaIQyiQY+zMB+Gz3eLswjPcCfikO6eCdr55TIza54bwurfdFA/B w5++n3VFL3IV9nWElrHpY3WSi8cVBM/6cRoLGeBI/wOmrH8uoZoi4NNn35EHE+4HQW/Y S+u6OGzlKrXJrJhnDQWOU8EPoZKvrSZA59WJQpwVgIM7/rIy73nxn6jgLVjs5Ject5Am 1XcMd9vQUu8AMXY8ABbeI0iBeupjBaCbA61YRr0XYeY4VTgRNxA9Pu0xtyEKkLdhqU3m BoVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=2mDUSPGcPZzaMW7gML3LPCubye4TyOLT8f3zTeFZihs=; b=umVy3J+Qj8sj6pvlG3smgTc8724VR6aoWYJ+sXqOBjHMKtzr+9sDnU731SMsI0TsSV qdrsF76v0pt9SxKreTgYQxxlmUQKosPr7hW6s+zyrN9i6Svqarj+8/tJ/aLSPa4zflzt o3xpzEEph/nPzmlyGXVp/2dU1zEj9M/WTURse0kPU899GXy6++in6OoZyHx4VaXd5CVk dsubHv2QXbTwcAHHTwQiiStq0S317Qh71/UpVZ0MwfNjogK8lkvw+K48c2syr3sM83Q5 7KxIcWa/H+9iDHvzQXFmXsJsdIwSyNS5EsvlnoSJJ/uoUs3zXrn2Sdy6V5FWgz9aCTvd t3/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=a22bC37E; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14-20020a05600c0a4e00b0038ec8673f90si7587351wmq.55.2022.05.15.03.34.36; Sun, 15 May 2022 03:35:03 -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=@linutronix.de header.s=2020 header.b=a22bC37E; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235971AbiEOJCV (ORCPT + 99 others); Sun, 15 May 2022 05:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiEOJCT (ORCPT ); Sun, 15 May 2022 05:02:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD944F2B for ; Sun, 15 May 2022 02:02:17 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652605335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2mDUSPGcPZzaMW7gML3LPCubye4TyOLT8f3zTeFZihs=; b=a22bC37E63DPGgcF/cz1PLTXMxwvqwE5Kp+PQ0VF0jHQ0m9peE6Ue6mUsIqGSFnIv2qQwL nTN8sn/6BFGBP6WlL2ErTQYt+ZwrJYk7ccXnKdwRmmHOnG5bBJSCJYlFUqDZdDYV1oDVgS qkHyXRyBc1958ETMJ7qJdemW9yvK38LhcpYIv0KJXe2JyYNGZFF41b3cexDMBrvcnvCZrT +RhA7KFtNXGvpTrg9UnA715yqzW8lL+ak/moaxwSnJxvt4s+BUpIVOdbKPU0pr4CJubhas HywYq5cSza59BEFAsRU7a5Z0Uq63NhqIHROLx6zgBBGYQ+v51Yw8DVF2wY8ULA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652605335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2mDUSPGcPZzaMW7gML3LPCubye4TyOLT8f3zTeFZihs=; b=l0ei/dXdudkTpXgkRl5uoJzI+bBhcdRFKRkbbHQSjBtbrfr0fS5DeQhr6NQUU/DiIWjZu3 JDO8C2GHyWd5TpAQ== To: "Edgecombe, Rick P" , "kirill.shutemov@linux.intel.com" Cc: "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "hjl.tools@gmail.com" , "linux-mm@kvack.org" , "dave.hansen@linux.intel.com" , "aryabinin@virtuozzo.com" , "dvyukov@google.com" , "x86@kernel.org" , "ak@linux.intel.com" , "Lutomirski, Andy" , "glider@google.com" Subject: Re: [RFCv2 03/10] x86: Introduce userspace API to handle per-thread features In-Reply-To: <9e59305039f2c8077ee087313d1df5ff06028cfe.camel@intel.com> References: <20220511022751.65540-1-kirill.shutemov@linux.intel.com> <20220511022751.65540-5-kirill.shutemov@linux.intel.com> <20220513230958.dbxp6m3y3lnq74qb@black.fi.intel.com> <543eb3ff98f624c6cfa1d450ac3e9ae8934c7c38.camel@intel.com> <87k0aose62.ffs@tglx> <9e59305039f2c8077ee087313d1df5ff06028cfe.camel@intel.com> Date: Sun, 15 May 2022 11:02:15 +0200 Message-ID: <87zgjjqico.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 14 2022 at 23:06, Edgecombe, Rick P wrote: > On Sat, 2022-05-14 at 10:37 +0200, Thomas Gleixner wrote: >> > "On success, arch_prctl() returns positive values; on error, -1 is >> > returned, and errno is set to indicate the error." >> >> Why? >> >> prctl(GET, &out) >> >> is the pattern used all over the place. > > It seems better to me, but we also need to pass something in. > > The idea of the "enable" operation is that userspace would pass in all > the features that it wants in one call, and then find out back what was > successfully enabled. So unlike the other arch_prctl()s, it wants to > pass something in AND get a result in one arch_prctl() call. It doesn't > need to check what is supported ahead of time. Since these enabling > operations can fail (OOM, etc), userspace has to handle unexpected per- > feature failure anyway. So it just blindly asks for what it wants. I'm not convinced at all, that this wholesale enabling of independent features makes any sense. That would require: - that all features are strict binary of/off which is alredy not the case with LAM due to the different mask sizes. - that user space knows at some potentially early point of process startup which features it needs. Some of them might be requested later when libraries are loaded, but that would be too late for others. Aside of that, if you lump all these things together, what's the semantics of this feature lump in case of failure: Try to enable the rest when one fails, skip the rest, roll back? Also such a feature lump results in a demultiplexing prctl() which is code wise always inferior to dedicated controls. > Any objections to having it write back the result in the same > structure? Why not. > Otherwise, the option that used to be used here was a "status" > arch_prctl(), which was called separately to find out what actually got > enabled after an "enable" call. That fit with the GET/SET semantics > already in place. > > I guess we could also get rid of the batch enabling idea, and just have > one "enable" call per feature too. But then it is syscall heavy. This is not a runtime hotpath problem. Those prctls() happen once when the process starts, so having three which are designed for the individual purpose instead of one ill defined is definitely the better choice. Premature optimization is never a good idea. Keep it simple is the right starting point. If it really turns out to be something which matters, then you can provide a batch interface later on if it makes sense to do so, but see above. Thanks, tglx