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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B21A2C433F5 for ; Thu, 12 May 2022 12:02:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CC246B0074; Thu, 12 May 2022 08:02:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17B0B6B0075; Thu, 12 May 2022 08:02:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 043506B0078; Thu, 12 May 2022 08:02:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E569C6B0074 for ; Thu, 12 May 2022 08:02:57 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1A92A604FD for ; Thu, 12 May 2022 12:02:53 +0000 (UTC) X-FDA: 79456954668.29.5572956 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf19.hostedemail.com (Postfix) with ESMTP id A03E21A00AF for ; Thu, 12 May 2022 12:02:44 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652356970; 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=0TDK3FCVRTz87zaUbyq9enp7BRasruSrvfPhIqvEbrA=; b=oGONUfWPrupXQpuMINj0gDWWK+uuFnS9UjxgbDtMqCJhaIi4NMmZvHnYUuiDeosbeX4Z9I Bf9uKD/Ly1S+wigL2KvU0CueTVZgaRJ66O+b/oO4SRkaqWADH1/hCEM/uVvhj0qVSiLXCS +v9GB28oACZ640BIHGtsadqH89lqjT+RG8Rc89JYKLM6qiCF7qDHjOjXfyb6oOr4qYL/6D XNOCfEs0jfGeXo9aeFvWToG1B8Qe6mTXqigKG2dSxQBbKAABwi0flVfbdPnHi1qNgOuPqI BrAo6PTgBhdBtiOTT9GgIhSeyj4LX1nWXL+7seSyVHw7Ow+/h/E/cJQOPg6MAg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652356970; 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=0TDK3FCVRTz87zaUbyq9enp7BRasruSrvfPhIqvEbrA=; b=L8/lKOjs5l1lxZa3s6AqtfYIEEq1nHtEtgbWnlgbayv16zFi26kbpDUcbi1FGGVdS0OsS3 ZuAps1ijRnp8/zBA== To: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: Re: [RFCv2 03/10] x86: Introduce userspace API to handle per-thread features In-Reply-To: <20220511022751.65540-5-kirill.shutemov@linux.intel.com> References: <20220511022751.65540-1-kirill.shutemov@linux.intel.com> <20220511022751.65540-5-kirill.shutemov@linux.intel.com> Date: Thu, 12 May 2022 14:02:50 +0200 Message-ID: <87o803vtzp.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Stat-Signature: d6mt6zb1ggrdcif5qkw3gn689jhcjn4d X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A03E21A00AF Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=oGONUfWP; dkim=pass header.d=linutronix.de header.s=2020e header.b="L8/lKOjs"; spf=pass (imf19.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Rspam-User: X-HE-Tag: 1652356964-261148 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, May 11 2022 at 05:27, Kirill A. Shutemov wrote: > Add three new arch_prctl() handles: > > +static long thread_feature_prctl(struct task_struct *task, int option, > + unsigned long features) Bah. I really hate the task pointer on all these x86 prctls. @task must always be current, so this @task argument is just confusion. > +{ > + const unsigned long known_features = 0; > + > + if (features & ~known_features) > + return -EINVAL; This implementation allows to task->read features_[locked] with @features == 0. That should be documented somewhere. > + if (option == ARCH_THREAD_FEATURE_LOCK) { > + task->thread.features_locked |= features; > + return task->thread.features_locked; > + } > + /* Do not allow to change locked features */ > + if (features & task->thread.features_locked) > + return -EPERM; > + > + if (option == ARCH_THREAD_FEATURE_DISABLE) { > + task->thread.features &= ~features; > + goto out; > + } > + > + /* Handle ARCH_THREAD_FEATURE_ENABLE */ > + > + task->thread.features |= features; > +out: > + return task->thread.features; Eyes bleed. if (option == ARCH_THREAD_FEATURE_ENABLE) task->thread.features |= features; else task->thread.features &= ~features; return task->thread.features; It's bloody obvious from the code that the counterpart of enable is disable, no? So neither the goto nor the 'comment the obvious' is useful in any way. Thanks, tglx