Received: by 10.192.165.148 with SMTP id m20csp2281982imm; Thu, 26 Apr 2018 08:31:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqs17NUSj2vLb80aULlnfkZnzyPJ/vxni5n1J3uIVc0ztP4tGskBfCHB1wwoA4m/+61FB4H X-Received: by 10.101.80.1 with SMTP id f1mr696819pgo.240.1524756698214; Thu, 26 Apr 2018 08:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524756698; cv=none; d=google.com; s=arc-20160816; b=suSEz0gDD9mKaXky0Oa1czELrRjWxrVudhLDvfVkuUe1xWJKPMbd08s4R3OQkIMH3U d4wd1kE38tyjxEG4INRtaAbhU3TDB6StSOw9COaogbJXsTr1t/nBkJmY6D+11c4GSgF5 PHdowMrv3d+TSAG2H8kC2SPlAleEofGkK9+XJZk2/kffG9IkDBtBhSKLNubRqgk8zr7u CcLP5aUkJX//YT1+zdg0banRw19bnQ/ghFm5eW89vdTtjMbSW5Ak6EO2ajDL8xWeXl4x U+G0EblHZdTm/KyUICoA/S+3oPcdlHI/q4b5PfbHu4WrOP4ptVMM4/hC2b2GsRVSsbsk +LXQ== 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=kIVk5cpMIYsnOoXxxJx4o9Sv082sQINGGiBArc/zgJ0=; b=GceTZuwD+WJXQol2PBLSGEZfZ45EQX66algM3YeQMi/ltlncLixsCXERNw1X0kna5/ D8zlwYQ9O6soRQ8Fy79XLnF43hV1uyXHMH05K/bsspKUuARQVo8UptZ+tzfZT/BaLZb4 slins58XghLOqbQ9IaFuQdosU9Fwgm22ZD5HHK6uy9ZXpiZEu4Bs6QD2Hhqod1kCga0n Ztk+zdBXfzVe2TfOympfWyAlwqj5FbhuJ1UWwze4oVfF65CPdbZC/CYNzxYY1SbAZUFm RqM5a6RImWW4H9T9dam+946+wsaZkIi+OvaRPGi4CWInuPnaxGdMABdP5jreDnkCnv8K HmlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WzIZLGZM; 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 q26si15315082pgv.585.2018.04.26.08.31.23; Thu, 26 Apr 2018 08:31:38 -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=@amarulasolutions.com header.s=google header.b=WzIZLGZM; 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 S1756745AbeDZPaI (ORCPT + 99 others); Thu, 26 Apr 2018 11:30:08 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33235 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756627AbeDZPaD (ORCPT ); Thu, 26 Apr 2018 11:30:03 -0400 Received: by mail-wr0-f195.google.com with SMTP id o4-v6so6941013wrm.0 for ; Thu, 26 Apr 2018 08:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kIVk5cpMIYsnOoXxxJx4o9Sv082sQINGGiBArc/zgJ0=; b=WzIZLGZM3G+zYG8IYzkycIQjKhOCrjXKDRWy6+wdZsCiHzuO5WMgkRWwq7XSjWzUng CoKVyI6lnnL1mOQljpngx0/NwrLBDzX1y0kLw3SEMhQJWxrLHn2rkfWbS4JpxAFZpyMi mHcevG//ZZlEh6LBDVXLTX8JsNcTvLg1pR8DQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kIVk5cpMIYsnOoXxxJx4o9Sv082sQINGGiBArc/zgJ0=; b=OisrgnG8hStfQf/6yX7zLb/ZC4TRcMyU+zQx2604nBlryc9G9xOqRexxSUsXzyNxVj 5a4veFJA1HbyQxJ7VO9AHyBanrUTUdwdWFJHmfDmPicKxvAqd+N4uh7O9VKCSAzq577Q YWxD0jIjPCOdFC2D0VkSEXhHU2TmzvM+bzRaNjRKq9TzoEnkUcu0cfcZvdnApNRKYPZD WNsqzt07kqpkzEEhXIG3kHsXjE4MO8nsxSa80b50jLLrCAo4HbbFI1/nrzbWTszmUhFS lBM83Uob8uDa8D0pDLgqAHpFn610Uo6QHNK8ZdxTdS1dgb+cTVDNW9f/bcOrG4MfL8b4 +85w== X-Gm-Message-State: ALQs6tCGIlxbuPtZg9z4QHPJidAH+taiZEG+SGOHY32uIOJobcks5fa1 MsYMUl8ov5vFMxco1qoKmFKghA== X-Received: by 2002:adf:8756:: with SMTP id 22-v6mr6753246wrz.117.1524756601948; Thu, 26 Apr 2018 08:30:01 -0700 (PDT) Received: from andrea (85.100.broadband17.iol.cz. [109.80.100.85]) by smtp.gmail.com with ESMTPSA id b5-v6sm19373857wrf.40.2018.04.26.08.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 08:30:00 -0700 (PDT) Date: Thu, 26 Apr 2018 17:29:42 +0200 From: Andrea Parri To: Kirill Tkhai Cc: akpm@linux-foundation.org, peterz@infradead.org, oleg@redhat.com, viro@zeniv.linux.org.uk, mingo@kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, riel@redhat.com, mhocko@suse.com, tglx@linutronix.de, kirill.shutemov@linux.intel.com, marcos.souza.org@gmail.com, hoeun.ryu@gmail.com, pasha.tatashin@oracle.com, gs051095@gmail.com, ebiederm@xmission.com, dhowells@redhat.com, rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Alan Stern , Will Deacon , Boqun Feng Subject: Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner() Message-ID: <20180426152942.GA2737@andrea> References: <152473763015.29458.1131542311542381803.stgit@localhost.localdomain> <152474046779.29458.5294808258041953930.stgit@localhost.localdomain> <20180426123542.GA819@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: > On 26.04.2018 15:35, Andrea Parri wrote: [...] > > > > Mmh, it's possible that I am misunderstanding this statement but it does > > not seem quite correct to me; a counter-example would be provided by the > > test at "tools/memory-model/litmus-tests/SB+mbonceonces.litmus" (replace > > either of the smp_mb() with the sequence: > > > > spin_lock(s); spin_unlock(s); spin_lock(s); spin_unlock(s); ). > > > > BTW, your commit message suggests that your case would work with "imply > > an smp_wmb()". This implication should hold "w.r.t. current implementa- > > tions". We (LKMM people) discussed changes to the LKMM to make it hold > > in LKMM but such changes are still in our TODO list as of today... > > I'm not close to LKMM, so the test you referenced is not clear for me. The test could be concisely described by: {initially: x=y=0; } Thread0 Thread1 x = 1; y = 1; MB MB r0 = y; r1 = x; Can r0,r1 be both 0 after joining? The answer to the question is -No-; however, if you replaced any of the MB with the locking sequence described above, then the answer is -Yes-: full fences on both sides are required to forbid that state and this is something that the locking sequences won't be able to provide (think at the implementation of these primitives for powerpc, for example). > Does LKMM show the real hardware behavior? Or there are added the most > cases, and work is still in progress? Very roughly speaking, LKMM is an "envelope" of the underlying hardware memory models/architectures supported by the Linux kernel which in turn may not coincide with the observable behavior on a given implementation /processor of that architecture. Also, LKMM doesn't aim to be a "tight" envelope. I'd refer to the documentation within "tools/memory-model/"; please let me know if I can provide further info. > > In the patch I used the logic, that the below code: > > x = A; > spin_lock(); > spin_unlock(); > spin_lock(); > spin_unlock(); > y = B; > > cannot reorder much than: > > spin_lock(); > x = A; <- this can't become visible later, that spin_unlock() > spin_unlock(); > spin_lock(); > y = B; <- this can't become visible earlier, than spin_lock() > spin_unlock(); > > Is there a problem? As mentioned in the previous email, if smp_wmb() is what you're looking for then this should be fine (considering current implementations; LKMM will likely be there soon...). BTW, the behavior in question has been recently discussed on the list; c.f., for example, the test "unlock-lock-write-ordering" described in: http://lkml.kernel.org/r/1519301990-11766-1-git-send-email-parri.andrea@gmail.com as well as 0123f4d76ca63b7b895f40089be0ce4809e392d8 ("riscv/spinlock: Strengthen implementations with fences") Andrea > > Kirill