Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5708728imm; Tue, 26 Jun 2018 16:42:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdq6r95RSXW3fR9kjeWrosv3zyWsdZw+pdbCjZgdj4bA5AuxNWPR6uu6Gwz7yROTHELL+J2 X-Received: by 2002:a62:5582:: with SMTP id j124-v6mr3511609pfb.20.1530056567502; Tue, 26 Jun 2018 16:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530056567; cv=none; d=google.com; s=arc-20160816; b=fpASxDpMxk8OPMuemXKl2LAQKLUceQo25Rc9Z6rbzdIcV5QflJZSrssaMOqXOgjUP1 WJOmA4KbM8OR8W4yKJWkSY4i5goweIVkM8WItsKgmyz2CpVner7VZiarAMSoKFPCYQJ8 6fUH8c7AKD+ntY1+VjBZRZlR8OeKTC2XFt8Av6L2BAdosRy6NBeJ+FoxEzNGZTWQCM3f FRgm/s3LQgH7aFgRTzpMbEBCZCXKBbEUjq/XWttyZ9GAj0xZ/BlvR9c2XohUdudXP+ac ZG02KnK/y/Wp4buILi23YusxNwx1nquQy/opxNpT0EBeygiILOYNg45+Zz2CK78Ll8AH DyWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=sgO3y5y8ILyYqtUhal+y5a6Q/m8hk5bFpFO0IKwHBbA=; b=tK8au7bhisbHrzzsW681IalecdHYk9nQiuT9DQBVV556VwtuaMFn3pymq6vnFZpYBf 9pTInNJ0RnXSg/p/MtMPg9VI3ybji55AGjs9K/rR7Ra4gZQp4JeaFqqL9c+CrYpKguZP eRfQt+AvuZqqTeADz7KgzeXbRmMEl/oxcmwDoai67/qqRN/kKFlkaY3U9iJsCRobxwHe MFEk2zP4rceg/ULIvb4keAl6uh9pyjstQ//SoY7w5N8rMeInN82TyHfFVjyLxHo/lzYQ 5AQmdyQU3de+96zaSJxaXeIdFfC8ZKqsrTC8Quv/nIN8NF+69frgDKu3i8jh5WGunsMr u+Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eaC3d+M1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d132-v6si2233049pga.355.2018.06.26.16.42.02; Tue, 26 Jun 2018 16:42:47 -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=pass header.i=@gmail.com header.s=20161025 header.b=eaC3d+M1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934157AbeFZSxU (ORCPT + 99 others); Tue, 26 Jun 2018 14:53:20 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:46503 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933266AbeFZSxT (ORCPT ); Tue, 26 Jun 2018 14:53:19 -0400 Received: by mail-vk0-f68.google.com with SMTP id b134-v6so10651439vke.13 for ; Tue, 26 Jun 2018 11:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sgO3y5y8ILyYqtUhal+y5a6Q/m8hk5bFpFO0IKwHBbA=; b=eaC3d+M1Ct939uFn5MNpnIiKvLJZP2QVuiQH+q79PcF1jabRLuvw9nXQ3Nbnk9R2oR +PWI2QNAzZLRhEMUGh1kkGImjwqOkROJkVsaj1hbICP0tk81SLIgBMbfG46S5RgUCdA2 h/yJ4Oj8oY8RPw5811MCEuV3OqZ6o+d6hQFFRPh4T/iukcYTQLRFeKks2VlNgpvvzcuP 3r8W+nUea4tBinF/DEl2zxru1wDFmZkSHEg1mfgMVgWjl2FB09n7vMRH5e8GbS5cuz0J yxwz8GWbYbMXfwtQWr7VElGjoCAsFlN6OjFhR6hz1lEOT4pMtQ4pc2EhLHBDakXa0wdo ARkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sgO3y5y8ILyYqtUhal+y5a6Q/m8hk5bFpFO0IKwHBbA=; b=kTsXfuoje4v/ybIcw6iARRagJ/+QXyzjKdOeCT550Oe+2st3sBfz6f4tJrREolpU1S pk4pVnDSaRjaMQUPMt+GIw+RjD19PUEXrMt3Ch7aQJOfJQzIZXt2tbWhNgE0CtVUGwsd +oY3KWTwac8//wA3oHXFNlzA0ptW8kd/ZPcTdmi/0l8dglOV9hPCIZWVlxkm9BmPn09N 3qbqfUek3nsaAVMECreBdhc+OMirh8/LzokxKEE/ide25Yp5kZ/I8zmfbN4ZoHsUNct1 xGEVtqk3bpEncH3+KIYxy7buT4E1FK3bFIjCYsymVaKhlZWXZOhgB0N729t+aXi3c+ib qVFA== X-Gm-Message-State: APt69E2TyieSA3pD897axgzhxb+dw2mpAnyS2CjgxNBeGrF4OPt4nlCu n4F2kpjkJxFsGmHRaXfmc+ziUOJI8cwBHslp/N4= X-Received: by 2002:a1f:82c7:: with SMTP id e190-v6mr1733478vkd.187.1530039198813; Tue, 26 Jun 2018 11:53:18 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:8b02:0:0:0:0:0 with HTTP; Tue, 26 Jun 2018 11:53:18 -0700 (PDT) In-Reply-To: <20180625105952.3756-2-mark.rutland@arm.com> References: <20180625105952.3756-1-mark.rutland@arm.com> <20180625105952.3756-2-mark.rutland@arm.com> From: Andy Shevchenko Date: Tue, 26 Jun 2018 21:53:18 +0300 Message-ID: Subject: Re: [PATCHv2 01/11] atomic/tty: Fix up atomic abuse in ldsem To: Mark Rutland Cc: Linux Kernel Mailing List , Will Deacon , "Peter Zijlstra (Intel)" , Boqun Feng , Peter Hurley Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Good fix! Reviewed-by: Andy Shevchenko -- With Best Regards, Andy Shevchenko