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=-9.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL 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 EA1B9C4360C for ; Fri, 27 Sep 2019 05:06:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C9A820863 for ; Fri, 27 Sep 2019 05:06:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oMF5sj8v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C9A820863 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF7038E002F; Fri, 27 Sep 2019 01:06:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA7C28E002A; Fri, 27 Sep 2019 01:06:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C968F8E002F; Fri, 27 Sep 2019 01:06:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A86848E002A for ; Fri, 27 Sep 2019 01:06:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 2F9E62C33 for ; Fri, 27 Sep 2019 05:06:56 +0000 (UTC) X-FDA: 75979516032.05.sink79_76ae1b3de0b17 X-HE-Tag: sink79_76ae1b3de0b17 X-Filterd-Recvd-Size: 6984 Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Sep 2019 05:06:55 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id h144so12969451iof.7 for ; Thu, 26 Sep 2019 22:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=krKHZZkb69YAEepgcIGe9YVo4hDkzfmJcUg4dwIu1i0=; b=oMF5sj8vXSnIK3NCKROqLeM/NQHiBK8+i6p7zPRhuLLvZmWwz+JMmMcJfkCsvWn9sP +5bx3yacV5cBZNlu43E6RsF9W4N6XGPoSn0aqTqrKtcPnSXW5vaiFXWtFLaaGTgOBihC J4poKQwPUIwcKU051JP9Lx2+2GDzbiM6O6OZcmrvU13h/tCBmmljMO0Is5ml8jDUkgkN E+MTdmkZuQvAtr23Cyn8kXVigA8Kzf1+WybOYjgNr2j/0c+OKFf3BS1ybeZ2oTPK+slc vjfcdkhz/V1q9VfrJF/7dQPiVOWU/B1xRsnnGERu3ZDxta5qc8f0UkEp1/qGhuUZGJs9 jYew== 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=krKHZZkb69YAEepgcIGe9YVo4hDkzfmJcUg4dwIu1i0=; b=HqxMSGHhx0nnFrGGsX5jHaUbh7IYfXz+RaF9Z5burCuNF++H5v6Dj35q4r4XEMCmUV 0KyyFsDDQ/nTOr3pBWyZanQoA5nYuuoulzoEzOLj5JHV+YqREJJH8P3i4oHbvDD8pElc NBQ6BYv0j/rcvOUpv/WDmNAZx643KyedEIhIZPhnzzbdQ+dDUJEhJYtlLNtKHWdrKhTh Wh2zfq9LD5GMPOldOVUJlCt8ZotWlc4oQGwArMeDQpyLLjvTKNwbaecH2LZ7GyitJtpJ cGAMNGvoWb2OzNFw2m0sH0+34RRo6jElrSKmWpKQwqx2aBI5Ixuw9dzRzs6cSsSO4uRE d9Ag== X-Gm-Message-State: APjAAAXNjQbr9Pb0ms6I/JY+klnGndDXloI2h2d4wsBSvXnHMKT1cdZR Op4s2bnP2VXIH0Ys4zXK3xKRRA== X-Google-Smtp-Source: APXvYqwZZP5MzaEtuv8r5/DxdCIuoO8yJuJLH7ISQ+4f6XWgpqvn7fkWE/+/eqa9rthVy80/L+OuSg== X-Received: by 2002:a5d:8911:: with SMTP id b17mr7048982ion.287.1569560814503; Thu, 26 Sep 2019 22:06:54 -0700 (PDT) Received: from google.com ([2620:15c:183:0:9f3b:444a:4649:ca05]) by smtp.gmail.com with ESMTPSA id h62sm1132272ild.78.2019.09.26.22.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 22:06:53 -0700 (PDT) Date: Thu, 26 Sep 2019 23:06:48 -0600 From: Yu Zhao To: John Hubbard Cc: "Kirill A. Shutemov" , Peter Zijlstra , Andrew Morton , Michal Hocko , "Kirill A . Shutemov" , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Vlastimil Babka , Hugh Dickins , =?iso-8859-1?B?Suly9G1l?= 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 , Mark Rutland , Alexander Duyck , Pavel Tatashin , David Hildenbrand , Juergen Gross , Anthony Yznaga , Johannes Weiner , "Darrick J . Wong" , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 3/4] mm: don't expose non-hugetlb page to fast gup prematurely Message-ID: <20190927050648.GA92494@google.com> References: <20190914070518.112954-1-yuzhao@google.com> <20190924232459.214097-1-yuzhao@google.com> <20190924232459.214097-3-yuzhao@google.com> <20190925082530.GD4536@hirez.programming.kicks-ass.net> <20190925222654.GA180125@google.com> <20190926102036.od2wamdx2s7uznvq@box> <9465df76-0229-1b44-5646-5cced1bc1718@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9465df76-0229-1b44-5646-5cced1bc1718@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Thu, Sep 26, 2019 at 08:26:46PM -0700, John Hubbard wrote: > On 9/26/19 3:20 AM, Kirill A. Shutemov wrote: > > On Wed, Sep 25, 2019 at 04:26:54PM -0600, Yu Zhao wrote: > >> On Wed, Sep 25, 2019 at 10:25:30AM +0200, Peter Zijlstra wrote: > >>> On Tue, Sep 24, 2019 at 05:24:58PM -0600, Yu Zhao wrote: > ... > >>> I'm thinking this patch make stuff rather fragile.. Should we instead > >>> stick the barrier in set_p*d_at() instead? Or rather, make that store a > >>> store-release? > >> > >> I prefer it this way too, but I suspected the majority would be > >> concerned with the performance implications, especially those > >> looping set_pte_at()s in mm/huge_memory.c. > > > > We can rename current set_pte_at() to __set_pte_at() or something and > > leave it in places where barrier is not needed. The new set_pte_at()( will > > be used in the rest of the places with the barrier inside. > > +1, sounds nice. I was unhappy about the wide-ranging changes that would have > to be maintained. So this seems much better. Just to be clear that doing so will add unnecessary barriers to one of the two paths that share set_pte_at(). > > BTW, have you looked at other levels of page table hierarchy. Do we have > > the same issue for PMD/PUD/... pages? > > > > Along the lines of "what other memory barriers might be missing for > get_user_pages_fast(), I'm also concerned that the synchronization between > get_user_pages_fast() and freeing the page tables might be technically broken, > due to missing memory barriers on the get_user_pages_fast() side. Details: > > gup_fast() disables interrupts, but I think it also needs some sort of > memory barrier(s), in order to prevent reads of the page table (gup_pgd_range, > etc) from speculatively happening before the interrupts are disabled. I was under impression switching back from interrupt context is a full barrier (otherwise wouldn't we be vulnerable to some side channel attacks?), so the reader side wouldn't need explicit rmb.