Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4053510ybv; Mon, 10 Feb 2020 11:22:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzOwELXRRXF+D6JoTdllyfU5q9PErbdF0af20LVJelXf3orEPmHo1US1ALA9/bNkFrOPddH X-Received: by 2002:a9d:7c99:: with SMTP id q25mr2250629otn.105.1581362566775; Mon, 10 Feb 2020 11:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362566; cv=none; d=google.com; s=arc-20160816; b=oWMEjrXYud+oikXGRMvd140gWzBqmIXpiOxPb9V4JxmxthR+G1cRmPQkMYqzBcPZfX RP9v20N6C5f/OfK3bThD+bN7gM7VlctjiKhC6cVILIZ7+SAN/thE7ocEVt0471qWTqGF Y6bGqiaMaIxmIgbLdSHwd6reeMfXpn+KUKZ1iL98vJ+mW+E8eGuJzwgxQbJM60tZMeFi MK9ZVJ36mSF+zZwqpvUW40Cs40WrNlJggmV4I5trFWVGuPWiMsqVPaLm5GFiezJGF2Pp SpAwV7iMlCQQBYMehSFt+oRJX/CZCQ8UPYNAFsXELEmvSaH8sDOlnRBYAu6g7hNlaHc6 0PAw== 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 :dkim-signature; bh=CiM52pTPVqz/skTBLeX1gYuocEamvKWE7EoYWXekqbE=; b=PbB4VTp1qB3MaGsZ2+hd8XIT+xeMLNoTfcuWhjf4uHnVFX/mi4rQehiUlKhHyVQ6Yv BbC2uCOejSyOFGReyGIAC8lt6H3bMVPYylCoDAs4RN3RYgqUOnlivNBdn2cPubsT0ugz MvP9OrfMNmclCL0hrOp6+/TkTT9fPeViryM/ioBUC5cVSyNVOuEaA6CDNWgzoHM8WuFk iGiXWfaU1va/+SPC1cBnWt8A7gBkNezLT6KlPfLJVaThaZ/tLn2TfLRQMGsNDng1XRuZ 9KG90HIxF+sheBnNBOF5tJUhFhR/+r1YCfhCQ+jsOJui6mG1eT31xITM08sLjYwovhEZ UvLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ToQYS2ee; 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 k128si517960oih.274.2020.02.10.11.22.33; Mon, 10 Feb 2020 11:22:46 -0800 (PST) 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=bombadil.20170209 header.b=ToQYS2ee; 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 S1727434AbgBJTWA (ORCPT + 99 others); Mon, 10 Feb 2020 14:22:00 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41562 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgBJTWA (ORCPT ); Mon, 10 Feb 2020 14:22:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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; bh=CiM52pTPVqz/skTBLeX1gYuocEamvKWE7EoYWXekqbE=; b=ToQYS2eeMN6pm+nzAjgrfjNuGk vx08Ib9g47C+wFMlqE6aEgHU+TDP9y769k0l5C5tTFhCrV4AuD33lgMv4AKJOW3I4/wpzQFGCmt7Q MlZTrZjdtonDDFjePt3EMml0AsAl+NF0OqM3TPqzKfKMbaIU0xlPMkax5sjaoJckafvIIv/T8b8LT KyhZZIX6Oni0VFLdoquOLWDQJcU401YytKrbPs0KKIC2KN/ke4KCvUx07wrbSyMt58ppqA5e7dOub R2zFcI2aTeD/OYDWzPgdAlffQICKo7+Yj9CIdVVFjaKjzZEnkIro//Y7ZztJm3jctCDlyAaaMJHN7 4bi6qvuA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1Ed1-0001zg-8H; Mon, 10 Feb 2020 19:21:55 +0000 Date: Mon, 10 Feb 2020 11:21:55 -0800 From: Matthew Wilcox To: Qian Cai Cc: akpm@linux-foundation.org, elver@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] mm/filemap: fix a data race in filemap_fault() Message-ID: <20200210192155.GM8731@bombadil.infradead.org> References: <1581354029-20154-1-git-send-email-cai@lca.pw> <20200210172511.GL8731@bombadil.infradead.org> <1581362448.7365.38.camel@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1581362448.7365.38.camel@lca.pw> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 02:20:48PM -0500, Qian Cai wrote: > On Mon, 2020-02-10 at 09:25 -0800, Matthew Wilcox wrote: > > On Mon, Feb 10, 2020 at 12:00:29PM -0500, Qian Cai wrote: > > > @@ -2622,7 +2622,7 @@ void filemap_map_pages(struct vm_fault *vmf, > > > if (page->index >= max_idx) > > > goto unlock; > > > > > > - if (file->f_ra.mmap_miss > 0) > > > + if (data_race(file->f_ra.mmap_miss > 0)) > > > file->f_ra.mmap_miss--; > > > > How is this safe? Two threads can each see 1, and then both decrement the > > in-memory copy, causing it to end up at -1. > > Well, I meant to say it is safe from *data* races rather than all other races, > but it is a good catch for the underflow cases and makes some sense to fix them > together (so we don't need to touch the same lines over and over again). My point is that this is a legitimate warning from the sanitiser. The point of your patches should not be to remove all the warnings!