Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5749519imm; Tue, 26 Jun 2018 17:44:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWAHGtnQigg6pn8uxDr8v4BgTJq7f9OPotCaEYB+yFJznxVn1vRzPiRfRM6JQCk8FsARxF X-Received: by 2002:a62:db05:: with SMTP id f5-v6mr3569863pfg.123.1530060248560; Tue, 26 Jun 2018 17:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530060248; cv=none; d=google.com; s=arc-20160816; b=mTjuy6yQiZxDdCVJfcP0OvazC1YcOPbqKdukcZkUR/eBep4pB8s3GGRW+/I+z1JoMS jr0i0pYkBlaxfThgNYX1cdOoVIEM5/Zn3yRRHSgJ7N23HrjVfzUQnsoCH6/CCAO84GuZ GLyfcXQyY42SnhhTi72EYl7yxSDUZPNOgXngpDKoyYVIn+lQLPE087KO6gORItFyKzfH eJifhy15xv+R5306WF7XxUZ8WRGW//XlKf0d21CWCG16utfne009Xoz5VtXVSUa+9X9q N2EtNzz0tyfJjPMfQIpRuk0RZ3xuZ2QsXjGkSMLcUaMnO3g2AoQDS3xJnVpaZQydSEOG BE8Q== 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:dkim-signature:arc-authentication-results; bh=e8KsyTF2KlklHPfgGTBztDCH30Tv7O8EAlKqO4JBMsE=; b=AbZUZpB/RW1OLcfieApgZ4QNz9jLa25CUuMjHW9z2k0fnmQtkT02axJP//hH/kD8Ic Ydwk/oEmv8o3Mp7Di5+UZJ8fq4cFSEA7Kz5yyGklqNiGf/7c5XGgbegJlu6V0n+oUkzU sgp19WBHaaVr3Vm/Fg81J/SeQw7wFdOZJAqcwy2DzDZzEanf6AyDo0n/4wg3jVV2Gycl qrSButsxUEotcC+MAR/YRHKlD+VLLb2v+QjPVZBeKMpa0FZr7Vm3aK/du7EtVTQpXChy hqwB2nVtewRjjNxjH2LwS40E+jupSFGc83oV6KrtMA8r1N7jX6YgfgjlWshwE6DTbF3n Yewg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Uxp1bLyF; 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 b2-v6si2670618plx.88.2018.06.26.17.43.54; Tue, 26 Jun 2018 17:44:08 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Uxp1bLyF; 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 S1754991AbeFZTav (ORCPT + 99 others); Tue, 26 Jun 2018 15:30:51 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54966 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752948AbeFZTaq (ORCPT ); Tue, 26 Jun 2018 15:30:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=e8KsyTF2KlklHPfgGTBztDCH30Tv7O8EAlKqO4JBMsE=; b=Uxp1bLyFtyQ2u/hEj1JNXIMHM jm2dDtcM95J6m1kQtMZVFcUQVVlG68fK0ZeU+xHPr7xFgmv7+RGhPmOPbTReEl2drX68hEO1SAblb GGE2sbfuJUa6UqQftNUjPKqirKD5k9DRPvR84OUBNsyDLhn9Wpvrw52qsJr0LZvbrjuNPV54VwelG ls715xyqEowZqUPoJfIjTlbVtRYqeBKYEBVOLVEHdh7vlQq4BQ73B4FGC973WkVm9DWLBzF+kP8RO azDqKAu5nOeqjYG9So2xLx/gESSjdUfPGrxn0ONng28xsb8NLFKM8ZexGNbHkbcffBCsnpvfsy4U9 2rgtxUVZw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXtfl-0005Qx-Io; Tue, 26 Jun 2018 19:30:41 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 593382029FA0A; Tue, 26 Jun 2018 21:30:40 +0200 (CEST) Date: Tue, 26 Jun 2018 21:30:40 +0200 From: Peter Zijlstra To: Andy Shevchenko Cc: Mark Rutland , Linux Kernel Mailing List , Will Deacon , Boqun Feng , Peter Hurley Subject: Re: [PATCHv2 01/11] atomic/tty: Fix up atomic abuse in ldsem Message-ID: <20180626193040.GO2494@hirez.programming.kicks-ass.net> References: <20180625105952.3756-1-mark.rutland@arm.com> <20180625105952.3756-2-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 26, 2018 at 09:53:18PM +0300, Andy Shevchenko wrote: > On Mon, Jun 25, 2018 at 1:59 PM, Mark Rutland wrote: > > From: Peter Zijlstra > > > > Mark found ldsem_cmpxchg() needed an (atomic_long_t *) cast to keep > > working after making the atomic_long interface type safe. > > > > Needing casts is bad form, which made me look at the code. There are no > > ld_semaphore::count users outside of these functions so there is no > > reason why it can not be an atomic_long_t in the first place, obviating > > the need for this cast. > > > > That also ensures the loads use atomic_long_read(), which implies (at > > least) READ_ONCE() in order to guarantee single-copy-atomic loads. > > > > When using atomic_long_try_cmpxchg() the ldsem_cmpxchg() wrapper gets > > very thin (the only difference is not changing *old on success, which > > most callers don't seem to care about). > > > > So rework the whole thing to use atomic_long_t and its accessors > > directly. > > > > While there, fixup all the horrible comment styles. > > > > - ldsem_atomic_update(-LDSEM_WAIT_BIAS, sem); > > + atomic_long_add_return(-LDSEM_WAIT_BIAS, &sem->count); > > I suppose it's simple atomic_long_add() here? Different ordering rules for those two. I didn't look hard enough to see if that mattered here.