Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2777798imm; Thu, 24 May 2018 16:02:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoMCCcp8wA59osCgQpRj2DUkPZEJCfIjmuwV55utaKtm2FJ04a80DRswXrAa/8+f0Ks7KDl X-Received: by 2002:a65:62d9:: with SMTP id m25-v6mr7408852pgv.407.1527202927920; Thu, 24 May 2018 16:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527202927; cv=none; d=google.com; s=arc-20160816; b=PhORnwehOjTll214J4/qWO5Ywmnrr8AsNngT/Fv0kJwn/Czrd7O9wzhMEn1krriJqR abViU49SyCU15/9YABgIKtYdeZtK+pk+Y7gHtX4K/tkvFKyq5opGnIYN3sq5pHLjJFeN fhfwZUmAA0Vmvob2KE5HemAx6QYRLApzovwqCL6GtJNh5FzPmXaJsPcPEq55l1ltHvlF 0i+qaStBu5qnAE8hks1cV3qXQ7CoWaT+MjvGJG1wzlx8CER6DqwiGP3732mSoqzbchZZ 40ZAvhVMM6Jp/9F9IhHJ6GPWYvU7iGWwyrhveMFHuQwr9tPdNzETizDPKA/6rm+4RXAJ ipwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=4UEoo9r3rXGjQ8eIBTYw5Z5eJQ6SQkeADlmGfHU1UkQ=; b=zxrFN05TaecdclgNXwBewBIMxeVXy2PvY6/S4VzCIeNHIq0jeMZqxZF5b9nam47fS1 p9WIJtQvt+W0HpBwQz3V0gSC/omXKkbl+9yfH+wSrqw6nYHmjwjuFxkobjaCVCfsbAw9 xFmORx2wSqMDkBFT3ImjGn+U5QbgeClCncy1g7ZfyKorpb+7evUNL4CmSP4IYbTHqTuX sqhsXkUjUMkZx/ZbH1IZV2FQIAVYGdN4Qf2A2oY3YSUz+WMGfBDRhYbVfoJ37+VsvjmV HEymQbjfDikkYN/gz8s3hyx01YZOoxQAOpdo8iyEfRX3p3A+MxaLSZeUkrL9zchJg4W/ BoAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si2188492plj.311.2018.05.24.16.01.53; Thu, 24 May 2018 16:02:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968605AbeEXNKA (ORCPT + 99 others); Thu, 24 May 2018 09:10:00 -0400 Received: from foss.arm.com ([217.140.101.70]:44522 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965004AbeEXNJ7 (ORCPT ); Thu, 24 May 2018 09:09:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6EDF1596; Thu, 24 May 2018 06:09:58 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8E0A3F25D; Thu, 24 May 2018 06:09:57 -0700 (PDT) Date: Thu, 24 May 2018 14:09:49 +0100 From: Mark Rutland To: Will Deacon Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, mingo@kernel.org, linux-arm-kernel@lists.infradead.org, yamada.masahiro@socionext.com Subject: Re: [PATCH 6/9] asm-generic/bitops/atomic.h: Rewrite using atomic_fetch_* Message-ID: <20180524130948.f37eltocl5tnittp@lakrids.cambridge.arm.com> References: <1527159586-8578-1-git-send-email-will.deacon@arm.com> <1527159586-8578-7-git-send-email-will.deacon@arm.com> <20180524124410.GF12198@hirez.programming.kicks-ass.net> <20180524124734.GE8689@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180524124734.GE8689@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 24, 2018 at 01:47:39PM +0100, Will Deacon wrote: > On Thu, May 24, 2018 at 02:44:10PM +0200, Peter Zijlstra wrote: > > On Thu, May 24, 2018 at 11:59:43AM +0100, Will Deacon wrote: > > > +static inline void set_bit(unsigned int nr, volatile unsigned long *p) > > > { > > > + p += BIT_WORD(nr); > > > + atomic_long_fetch_or_relaxed(BIT_MASK(nr), (atomic_long_t *)p); > > > } > > > > > > +static inline void clear_bit(unsigned int nr, volatile unsigned long *p) > > > { > > > + p += BIT_WORD(nr); > > > + atomic_long_fetch_andnot_relaxed(BIT_MASK(nr), (atomic_long_t *)p); > > > } > > > > > > +static inline void change_bit(unsigned int nr, volatile unsigned long *p) > > > { > > > + p += BIT_WORD(nr); > > > + atomic_long_fetch_xor_relaxed(BIT_MASK(nr), (atomic_long_t *)p); > > > } > > > > Why use the fetch variants here? > > I noticed the same thing just now; I'll drop that and just use the > non-value-returning variants. It's shame that I can't do the same for > the lock.h unlock code, but we don't have non-returning release variants. As an aside, If I complete the autogeneration stuff, it'll be possible to generate those. I split out the necessary barriers in [1], but I still have a lot of other preparatory cleanup to do. IIUC, the void-returning atomic ops are relaxed, so trying to unify that with the usual rule that no suffix means fence will slow things down unless we want to do a treewide substitition to fixup for that. Thanks, Mark. [1] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?h=atomics/api-unification&id=c6b9ff2627d06776e427a7f1a7f83caeff3db536