Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9924271ybi; Wed, 24 Jul 2019 12:24:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/lgmGZ4jSWIazqRRwIESOwo9nxfB+y5O9a5sihys6ercPs3gt6SKGTEnUsH5ofZbdI29M X-Received: by 2002:aa7:8a92:: with SMTP id a18mr13034871pfc.216.1563996295036; Wed, 24 Jul 2019 12:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996295; cv=none; d=google.com; s=arc-20160816; b=Kd6d28r7wy4YsWqayQzCongZ0zwJzs3ZbI7U5HiOsPThpecuuhEBFPwQPgTuygwuat MtKPfqfwvZG3/OAFXc9nSEXMzwH6s/25V/7qT3aM+46xgjuKHEw8UFeSVf1uM3fDLXa1 U+e/q14qz7KkivzCw7dvAAoTrBfqJjLp8UWSKkMGmBpAkprOEKHFzkPVdbl9Wv+VQWJD TLL8oBpbkaap7aGbz/P4gxLX563kSwGBb/BdNOG9W+ZapmiuiaItQv7B4b6EUIjqdlEC 5BkrNwqwzrWDEg1qkVqrs++Vw4jUPymiJiQPrRSvxU1M1PkMhRW7IrLvnEuA4vZv4FJy 5APw== 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=/8SpAXACt/H0ZjS+gW4ox0Hhxo1Ofk7o0k1709Jn7z0=; b=XjxyDGKxuhC98M9gL40yxQVqlheAVklL9YvHgnCBwR370I3hH0MV4rQTKBGBzeHzWK mT9GaxJbSNsmkR5Ip2VURT9zqkSAUgaICfJy9slbu4ImFLBw/FDo6LmB4gdTq6q2z/v5 ZUT31RX+usgGlf0OfM1SzhfQIi9qxtIAV8al9CCEkUVT0ykHeRFM2+4AaSqxO26J1voR l1Dek7XJLHBftJkHnoMIk1oO19Y4YheYgYlr9jp1sFPMNfmoHIhC2s2VYclAgav2OaTO 78/7czvYqqrbuBQgLYMKMFy4dwZ/vlIGQB14f0xvmutPbqpsVxND6w7QC96HXBCCU8RL T4uQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si17936887pfc.54.2019.07.24.12.24.40; Wed, 24 Jul 2019 12:24:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387549AbfGXSZ0 (ORCPT + 99 others); Wed, 24 Jul 2019 14:25:26 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46677 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387480AbfGXSZ0 (ORCPT ); Wed, 24 Jul 2019 14:25:26 -0400 Received: by mail-qt1-f193.google.com with SMTP id h21so46410262qtn.13 for ; Wed, 24 Jul 2019 11:25:25 -0700 (PDT) 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; bh=/8SpAXACt/H0ZjS+gW4ox0Hhxo1Ofk7o0k1709Jn7z0=; b=PHwUigojGTITdp4CfOJsh3lXSNr6mbNszISJeROMNqCsVjRob6TzwSghkYBtSvE/7g 1aJ+LNW7pjgEAF8ZazGeB6Hu8vALnN0TFSoqzOtA+97TFO6vxIjVvq3pBWvzw4pDbe5Q 5Bk7BJ++FwnuelW0YKLFijm4HEDoLjiG3Ux6BbSP/S7wM+vdjeFj7aFYFbkknbEGvmM9 2yTxhtbTjAhqHfiSjgXhQZAqrqudDC1aH08op3x+SfCjKjy7uoXA8X0DdMktt8NowpF9 Aw2hIH50ZpC5My8DmUYKj5LPxDJayV8Wq5IgxWJODfXCkitQ6E3vYXuIz23PeOQqAS+0 4ElA== X-Gm-Message-State: APjAAAUjOmA5dWLf3ksZf6S5ZkUVLBHYb4o3HkCaIYq6uE7tWXsR/kwm DLguhRK6nLNbXvIl/bPlsh8CHA== X-Received: by 2002:ac8:74cb:: with SMTP id j11mr54557383qtr.67.1563992725087; Wed, 24 Jul 2019 11:25:25 -0700 (PDT) Received: from redhat.com (bzq-79-181-91-42.red.bezeqint.net. [79.181.91.42]) by smtp.gmail.com with ESMTPSA id z19sm22080696qkg.28.2019.07.24.11.25.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 11:25:24 -0700 (PDT) Date: Wed, 24 Jul 2019 14:25:15 -0400 From: "Michael S. Tsirkin" To: Jason Gunthorpe Cc: Jason Wang , syzbot , aarcange@redhat.com, akpm@linux-foundation.org, christian@brauner.io, davem@davemloft.net, ebiederm@xmission.com, elena.reshetova@intel.com, guro@fb.com, hch@infradead.org, james.bottomley@hansenpartnership.com, jglisse@redhat.com, keescook@chromium.org, ldv@altlinux.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, luto@amacapital.net, mhocko@suse.com, mingo@kernel.org, namit@vmware.com, peterz@infradead.org, syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk, wad@chromium.org Subject: Re: WARNING in __mmdrop Message-ID: <20190724142417-mutt-send-email-mst@kernel.org> References: <20190723010156-mutt-send-email-mst@kernel.org> <124be1a2-1c53-8e65-0f06-ee2294710822@redhat.com> <20190723032800-mutt-send-email-mst@kernel.org> <20190723062221-mutt-send-email-mst@kernel.org> <9baa4214-67fd-7ad2-cbad-aadf90bbfc20@redhat.com> <20190723110219-mutt-send-email-mst@kernel.org> <20190724040238-mutt-send-email-mst@kernel.org> <20190724165317.GD28493@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724165317.GD28493@ziepe.ca> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 24, 2019 at 01:53:17PM -0300, Jason Gunthorpe wrote: > On Wed, Jul 24, 2019 at 04:05:17AM -0400, Michael S. Tsirkin wrote: > > On Wed, Jul 24, 2019 at 10:17:14AM +0800, Jason Wang wrote: > > > So even PTE is read speculatively before reading invalidate_count (only in > > > the case of invalidate_count is zero). The spinlock has guaranteed that we > > > won't read any stale PTEs. > > > > I'm sorry I just do not get the argument. > > If you want to order two reads you need an smp_rmb > > or stronger between them executed on the same CPU. > > No, that is only for unlocked algorithms. > > In this case the spinlock provides all the 'or stronger' ordering > required. > > For invalidate_count going 0->1 the spin_lock ensures that any > following PTE update during invalidation does not order before the > spin_lock() > > While holding the lock and observing 1 in invalidate_count the PTE > values might be changing, but are ignored. C's rules about sequencing > make this safe. > > For invalidate_count going 1->0 the spin_unlock ensures that any > preceeding PTE update during invalidation does not order after the > spin_unlock > > While holding the lock and observing 0 in invalidating_count the PTE > values cannot be changing. > > Jason Oh right. So prefetch holds the spinlock the whole time. Sorry about the noise. -- MST