From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3AFDC432C1 for ; Tue, 24 Sep 2019 11:23:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7829020872 for ; Tue, 24 Sep 2019 11:23:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="JCXAHKAe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7829020872 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 119EC6B0006; Tue, 24 Sep 2019 07:23:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CC316B0007; Tue, 24 Sep 2019 07:23:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFCA56B000C; Tue, 24 Sep 2019 07:23:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id D16C26B0006 for ; Tue, 24 Sep 2019 07:23:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 7EE51180AD802 for ; Tue, 24 Sep 2019 11:23:18 +0000 (UTC) X-FDA: 75969578076.15.ghost17_1cce0a35ed945 X-HE-Tag: ghost17_1cce0a35ed945 X-Filterd-Recvd-Size: 5181 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Sep 2019 11:23:17 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id r4so1477315edy.4 for ; Tue, 24 Sep 2019 04:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fFhYFHjSj9wjqVDmFbFCUMCJqMZEDHU2eHaDtmiFh4I=; b=JCXAHKAebzdQwVmC1FyCywlDLC88/J/Z1kX31UlH8sfmMA2gtp9eRIpcR7dbjuiwW/ YExJfiY5ffHOsVxqyUOyNkbc8ZD/gqEl6S5cwCbK5JNzw2Ddl3RCOW2dB6tEYXh6sUgb 7OeQ5jUODU8+uf+zlPjCMPoU/f01+hx7J1JBCHmbRHHdXwKW617OyjxXJgoIBxBmgHvE VoUKiBVjV2fQkRTRPfoFg3qYZ6/fRrom7xTHTjUNMLUClf37y9Enx6+uw5CEKaSTpNrG uZEfYhf+6xQyzj54Ryu9uA298TUxAJnNNsOgHiCfZ4fdGB7C0Wtr4v/w5n4Eo1LqgG4I 7bsQ== 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=fFhYFHjSj9wjqVDmFbFCUMCJqMZEDHU2eHaDtmiFh4I=; b=WvQgP5vvrpiwwWm3pLOyGICQNGI5pC5O8r7vTaB9EbynntgHdm32APSNozjHgI+3pZ Zl8WFe3qAsLrVir49YickCMBTySGQQP7lalMXosdMHgdhEU5eKnbr620pS1fW+Nivlvy Aym3KAvSQfnS0rsxXKfvhrQVR8S3CfmKfusEJ4V77gLWv8kfsgyv53U9Btl8f4YmzCBm joEC7rvyJKhyb/59DXiJ4tgqup6lara6Z4ZENGuglB+E2jrvwmhAThqk++6pEFABuD12 ry4igQQPibdEZTtpwbdpzOKskifwRu6K3J5hqpGUd6bbCwzojvMjiwh90pTDX4J5dkC/ IUBw== X-Gm-Message-State: APjAAAVxgj03D1CWBV3bBUitMDnfDwk5Gjjb8aOSuTi0mFmH6wSzTkmd wksl+aeBER+PYkC766g3AgQ/zw== X-Google-Smtp-Source: APXvYqxaVwPqLRqZKj5sACDWXnix2WMaV/zu2ASKpiJMYUq4PJAoMrx4s2S39weu5gA5h2BCBLcW0Q== X-Received: by 2002:a17:906:af57:: with SMTP id ly23mr1895280ejb.269.1569324196369; Tue, 24 Sep 2019 04:23:16 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id z20sm314027edb.3.2019.09.24.04.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2019 04:23:15 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id C849D1022A6; Tue, 24 Sep 2019 14:23:16 +0300 (+03) Date: Tue, 24 Sep 2019 14:23:16 +0300 From: "Kirill A. Shutemov" To: Yu Zhao Cc: Andrew Morton , Michal Hocko , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , "Kirill A . Shutemov" , Vlastimil Babka , Hugh Dickins , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Andrea Arcangeli , "Aneesh Kumar K . V" , David Rientjes , Matthew Wilcox , Lance Roy , Ralph Campbell , Jason Gunthorpe , Dave Airlie , Thomas Hellstrom , Souptick Joarder , Mel Gorman , Jan Kara , Mike Kravetz , Huang Ying , Aaron Lu , Omar Sandoval , Thomas Gleixner , Vineeth Remanan Pillai , Daniel Jordan , Mike Rapoport , Joel Fernandes , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm: don't expose page to fast gup prematurely Message-ID: <20190924112316.324l7gqpdzhpiliq@box> References: <20190514230751.GA70050@google.com> <20190914070518.112954-1-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190914070518.112954-1-yuzhao@google.com> User-Agent: NeoMutt/20180716 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Sep 14, 2019 at 01:05:18AM -0600, Yu Zhao wrote: > We don't want to expose page to fast gup running on a remote CPU > before all local non-atomic ops on page flags are visible first. > > For anon page that isn't in swap cache, we need to make sure all > prior non-atomic ops, especially __SetPageSwapBacked() in > page_add_new_anon_rmap(), are order before set_pte_at() to prevent > the following race: > > CPU 1 CPU1 > set_pte_at() get_user_pages_fast() > page_add_new_anon_rmap() gup_pte_range() > __SetPageSwapBacked() SetPageReferenced() Is there a particular codepath that has what you listed for CPU? After quick look, I only saw that we page_add_new_anon_rmap() called before set_pte_at(). -- Kirill A. Shutemov