Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp231144pxk; Thu, 24 Sep 2020 04:26:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6EHHOqO1x9TQIofpZels6xsWaFcT7n1TaNULKDtzjPaIr+8xxgGQjEtoff98ZVLOUOIkl X-Received: by 2002:a17:906:454a:: with SMTP id s10mr501769ejq.138.1600946769260; Thu, 24 Sep 2020 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600946769; cv=none; d=google.com; s=arc-20160816; b=lZyuHDjZAeFZ/TxIufrofsNi6iloWO9zecf6HkoU7VDxP/2fjE3L9nYS9XwutXUYoK 693UpQskgAejM6vsMLGL7qTPI0cYCn3A9xvO6tx7Rf6qShzJVh6rB+1VHN9Y4f/qemSj P2NRWzXPNyToaDBJi9YFMR0NUTkKfPyPgOxZ/LxEqEDwPAIKvWY8zBYL0/xNWKIqAIZ5 d0TtGKWSMkl/3UnOqH5sZWIM6hAD7usI/oDwsLLcrYhg3VRoEkxNrijjREh7QXWAdhHy dx5pzMO5AMf8puqnkEEzi0IwItIkzojJTVK5jWHKsdabY4nL9oJRf15MdVHPDETazcP1 p+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LKUxmCaND0rMd4TqkVPk13jipt+snOdJO/HwxFGNvVc=; b=v/7vZd+yrncEWJuvJAx/8d5t4dbAVfox+BSoxUlV7lIolDiQeusd3U8g5jltEvWYgP Ntvm5/iYuis2trOc81m9mlJI9bYdWgNxU9UyCxP6kjcGHZutWDC270vtuEpOxI+fpR2J Dr8Qnvej3GrF/PgMHR0ueRy/9LFWK2wWSwiBB+H41rUe/xixqXqnyYLZkD9AXGzdzMuo GeMCc4THYAgQY9lAaVdGWxujqywBQMmSegWdPkRgyt7o6dnZuoSQnBP9zVbvrYX7W3KQ +3o+YOnotHv64EXgvN0/gUXQRDHZtVb1EBPDUElPy7ol4HgfMJK8s7crKI0t3B3woClL O+EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YJTYTmtZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk18si1864941ejb.172.2020.09.24.04.25.45; Thu, 24 Sep 2020 04:26:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YJTYTmtZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727407AbgIXLYp (ORCPT + 99 others); Thu, 24 Sep 2020 07:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727195AbgIXLYp (ORCPT ); Thu, 24 Sep 2020 07:24:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F215C0613CE; Thu, 24 Sep 2020 04:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LKUxmCaND0rMd4TqkVPk13jipt+snOdJO/HwxFGNvVc=; b=YJTYTmtZYUZeNGEgx90scbS7qo 5tQ7gYe7tUdKBUnsLlMoUjSiT0KxarH6WQVTUsP8IcdaPPdaKtVPbt6e9nTatqVTBmBFLISAWV8UL SGBw3sovX06wUyp+SihgpLVizAnUqIfZQz6XeqzCw6gX7kAWachwju1KoBUGYnV2G/tLxEnRcGt8p DdB5eZTHgVDOcowpDRveom1QhQBPRBeAGiE0mLmoPS5gUOBPuHAAhNoGMtVeIykWrUahes6USsO2k mAfZp1o5eEMtL7/nkx0rtB91Pyl+Yv8mcYzhFHegOsKGmJ2NV2lvuPkPaDgz3QsUggg/CicbivMC0 39dIXcLA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLPMg-0001am-3i; Thu, 24 Sep 2020 11:24:42 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4EC15300DB4; Thu, 24 Sep 2020 13:24:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3BB59203161DB; Thu, 24 Sep 2020 13:24:41 +0200 (CEST) Date: Thu, 24 Sep 2020 13:24:41 +0200 From: Peter Zijlstra To: Gabriel Krisman Bertazi Cc: luto@kernel.org, tglx@linutronix.de, keescook@chromium.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, willy@infradead.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, kernel@collabora.com Subject: Re: [PATCH v6 1/9] kernel: Support TIF_SYSCALL_INTERCEPT flag Message-ID: <20200924112441.GF2628@hirez.programming.kicks-ass.net> References: <20200904203147.2908430-1-krisman@collabora.com> <20200904203147.2908430-2-krisman@collabora.com> <20200911093221.GD1362448@hirez.programming.kicks-ass.net> <878sdgnkj6.fsf@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878sdgnkj6.fsf@collabora.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2020 at 04:08:45PM -0400, Gabriel Krisman Bertazi wrote: > peterz@infradead.org writes: > > > On Fri, Sep 04, 2020 at 04:31:39PM -0400, Gabriel Krisman Bertazi wrote: > >> +static inline void __set_tsk_syscall_intercept(struct task_struct *tsk, > >> + unsigned int type) > >> +{ > >> + tsk->syscall_intercept |= type; > >> + > >> + if (tsk->syscall_intercept) > >> + set_tsk_thread_flag(tsk, TIF_SYSCALL_INTERCEPT); > >> +} > > > > Did the above want to be: > > > > unsigned int old = tsk->syscall_intercept; > > tsk->syscall_intercept |= type; > > if (!old) > > set_tsk_thread_flag(tsk, TIF_SYSCALL_INTERCEPT) > > > > Hi Peter, > > Thanks for the review! > > I'm not sure this change gains us anything. For now, > __set_tsk_syscall_intercept cannot be called with !type, so both > versions behave the same, but my version is safe with that scenario. > This won't be called frequent enough for the extra calls to > set_tsk_thread_flag matter. Am I missing something? Your version will do set_tsk_thread_flag() for every invocation (assuming non-zero type). That's sub-optimal.