Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp304844pxa; Fri, 14 Aug 2020 04:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwffn2Kyjgums96xalB2DVsozRxdWnx7e0S0XXd/X64glvGzjihl6UsvL6ZaNol2oLjET4s X-Received: by 2002:a50:fd83:: with SMTP id o3mr1782507edt.170.1597406339696; Fri, 14 Aug 2020 04:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597406339; cv=none; d=google.com; s=arc-20160816; b=nLiLZpGnVtdJGSR1B7LZNoSqJNyRKQPIJKPqFcOBj1d7LvIhkH/Ic9BXbbWRROoHtA cLHEBvEJUwEbcIoVFhyNz4+HFJKTB9dTcMy7hY5EFAjbXIBwJrdQt3meJobj/vExbpre c/CLHfX7dgoGA4yncF/+yp4vNe5aHqKppJ7gEVWpvF676qy9yFjHD6kMKrfZeLxMmxqE nD/KFJhdXf2tW1qfLvrNQypN9ARIRDemLRTVBLEmBwLqb95bZqcCQh5jLLzvUnqoHiGT U0SOEWxaDOBG9bes00ywAEger/04PA5XxGvY5JIMIwZatQ3trr727u9X1fnki1wBebRQ W+Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ha+SI8q5lladiwXinHPEDCpxemW6nJJ/A8LF9/w9W4E=; b=fYTX8h0j/F1oZ8ckcUnPZiS4veIm/ZsK1g3oHC0xjcAT+wC97vGJQqtNfl8dSCrmAo UFvk2/yzh4s0qCl6L2IDMyHlRVd0N8oN2BHDh2G6L7U/mdsrhSiDoRghjbpcwTeVBm6A E7x+L4oRvUkDaqApELL4e8agVv7HB7lTgMTXvmPP4bnFstrvtWofwLFtsoKmMmBPDFZx MP3xN71nYMNXy8JLn0THxDdT/LGPVbtCnRCBgiemovhzz7QPoLk6kDN6B0Ck7Gg6VzQJ UuDqOkllBOnBaZVyd81jvwm8CBJ7Unjco/pDBHsnED7FVVI2T8oo99Dbgd3sPqKINyRV SDBw== ARC-Authentication-Results: i=1; mx.google.com; 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 x15si5169891eje.180.2020.08.14.04.58.36; Fri, 14 Aug 2020 04:58:59 -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; 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 S1727964AbgHNL2c (ORCPT + 99 others); Fri, 14 Aug 2020 07:28:32 -0400 Received: from foss.arm.com ([217.140.110.172]:33292 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbgHNL2c (ORCPT ); Fri, 14 Aug 2020 07:28:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9919B1063; Fri, 14 Aug 2020 04:28:31 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.33.165]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5A90F3F6CF; Fri, 14 Aug 2020 04:28:29 -0700 (PDT) Date: Fri, 14 Aug 2020 12:28:26 +0100 From: Mark Rutland To: Marco Elver Cc: Peter Zijlstra , "Paul E. McKenney" , Will Deacon , Arnd Bergmann , Dmitry Vyukov , Alexander Potapenko , kasan-dev , LKML , linux-arch Subject: Re: [PATCH 8/8] locking/atomics: Use read-write instrumentation for atomic RMWs Message-ID: <20200814112826.GB68877@C02TD0UTHF1T.local> References: <20200721103016.3287832-1-elver@google.com> <20200721103016.3287832-9-elver@google.com> <20200721141859.GC10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sorry to come to this rather late -- this comment equally applies to v2 so I'm replying here to have context. On Wed, Jul 22, 2020 at 12:11:18PM +0200, Marco Elver wrote: > On Tue, 21 Jul 2020 at 16:19, Peter Zijlstra wrote: > > > > On Tue, Jul 21, 2020 at 12:30:16PM +0200, Marco Elver wrote: > > > > > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > > > index 6afadf73da17..5cdcce703660 100755 > > > --- a/scripts/atomic/gen-atomic-instrumented.sh > > > +++ b/scripts/atomic/gen-atomic-instrumented.sh > > > @@ -5,9 +5,10 @@ ATOMICDIR=$(dirname $0) > > > > > > . ${ATOMICDIR}/atomic-tbl.sh > > > > > > -#gen_param_check(arg) > > > +#gen_param_check(meta, arg) > > > gen_param_check() > > > { > > > + local meta="$1"; shift > > > local arg="$1"; shift > > > local type="${arg%%:*}" > > > local name="$(gen_param_name "${arg}")" > > > @@ -17,17 +18,24 @@ gen_param_check() > > > i) return;; > > > esac > > > > > > - # We don't write to constant parameters > > > - [ ${type#c} != ${type} ] && rw="read" > > > + if [ ${type#c} != ${type} ]; then > > > + # We don't write to constant parameters > > > + rw="read" > > > + elif [ "${meta}" != "s" ]; then > > > + # Atomic RMW > > > + rw="read_write" > > > + fi > > > > If we have meta, should we then not be consistent and use it for read > > too? Mark? > > gen_param_check seems to want to generate an 'instrument_' check per > pointer argument. So if we have 1 argument that is a constant pointer, > and one that isn't, it should generate different instrumentation for > each. By checking the argument type, we get that behaviour. Although > we are making the assumption that if meta indicates it's not a 's'tore > (with void return), it's always a read-write access on all non-const > pointers. > > Switching over to checking only meta would always generate the same > 'instrument_' call for each argument. Although right now that would > seem to work because we don't yet have an atomic that accepts a > constant pointer and a non-const one. > > Preferences? Given the only non-rmw cases use the 'l' and 's' meta values, and those only have a single argument, I reckon it's preferable to special-case those specifically, e.g. case "{meta}" in l) rw="read";; s) rw="write";; *) rw="read_write";; esac ... then we can rework that in future if we ever need to handle multiple atomic variables that have distinct r/w/rw access types. Thanks, Mark.