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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 06B0CC433DB for ; Sat, 26 Dec 2020 21:07:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F74021D7A for ; Sat, 26 Dec 2020 21:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F74021D7A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D3AF88D0092; Sat, 26 Dec 2020 16:07:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEA5D8D0080; Sat, 26 Dec 2020 16:07:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDA028D0092; Sat, 26 Dec 2020 16:07:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id A44FD8D0080 for ; Sat, 26 Dec 2020 16:07:34 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6A4E6180AD81F for ; Sat, 26 Dec 2020 21:07:34 +0000 (UTC) X-FDA: 77636669628.15.fan77_611186f27485 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 464281814B0C1 for ; Sat, 26 Dec 2020 21:07:34 +0000 (UTC) X-HE-Tag: fan77_611186f27485 X-Filterd-Recvd-Size: 5413 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Sat, 26 Dec 2020 21:07:33 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id 23so15881515lfg.10 for ; Sat, 26 Dec 2020 13:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TLzZOIgPa8iJ9Qz8oeEG2djATaWpwCUP0i8Tl1Hc7Zg=; b=N6fEfq+jWauozbcMHPf/B0M4w8Cb6kqr3VPP7Q+3/4QNRt+Netvh3QJmjtws1fK7sj SLs93EdyJRwwErvnET7KD+AF9lnNMk7UFHq2G7xO97r/ulDnrwYmuUUpcMLSiJJNLzHx Fexyl7FzYf0NKSWDJXi29vPxcqWkkF8u2MRX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TLzZOIgPa8iJ9Qz8oeEG2djATaWpwCUP0i8Tl1Hc7Zg=; b=CWsi0oDb+ijf1d9Guf/BcCTgzfPLv+6Z/W7E/k4Vx8tkAlF384fkWxHpLS7Mqng31g /iyyBq0KOfbAcWI8p9j0joC5rrgxnok12J3I4hxsWSWSBe6n3h4/O2nOx/gtfHvsCbmF Q6kFOx+3gg+Cui2E/3cxrIPAifXrmDSTQw55FyLWRb2o+BxHQCz2fKrCFPk0f0B7w0Zo JYdEJiMUavzVYa3KwBNgN4DiCeCfvqvTSz336NUZ7orxuyRMh+t5AmmaCkNHK00CdVz9 1bClOQ0o+9iuAbctqixP6Siscb0VgVPI6eeHzBCtXSg8m8ZzoYX04hzpFmtpaq2dTMEr mZNw== X-Gm-Message-State: AOAM532Hh1z9b6p8o/vunhe93hl/RQz1KwP/U6SLy4iiKTINsu/QUYH7 jgHFwrvNnDEdl3JmyfkR4qAwWJs+B6BCmw== X-Google-Smtp-Source: ABdhPJymtSOaoDqK/bYGZt0DcSO7uK0rTuR9j33eyKoQlYQG+YKeLyBZE4GmQ4ZK8tRUrKLnLc+zjg== X-Received: by 2002:a2e:9d8e:: with SMTP id c14mr17798199ljj.7.1609016851888; Sat, 26 Dec 2020 13:07:31 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id l84sm4741498lfd.75.2020.12.26.13.07.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 26 Dec 2020 13:07:31 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id x20so15868257lfe.12 for ; Sat, 26 Dec 2020 13:07:30 -0800 (PST) X-Received: by 2002:a19:7d85:: with SMTP id y127mr17054973lfc.253.1609016850481; Sat, 26 Dec 2020 13:07:30 -0800 (PST) MIME-Version: 1.0 References: <20201217105409.2gacwgg7rco2ft3m@box> <20201218110400.yve45r3zsv7qgfa3@box> <20201219124103.w6isern3ywc7xbur@box> <20201222100047.p5zdb4ghagncq2oe@box> <20201225113157.e7hmluffh56fszfc@box> <20201226204335.dikqkrkezqet6oqf@box> In-Reply-To: <20201226204335.dikqkrkezqet6oqf@box> From: Linus Torvalds Date: Sat, 26 Dec 2020 13:07:14 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting To: "Kirill A. Shutemov" Cc: Hugh Dickins , Matthew Wilcox , "Kirill A. Shutemov" , Will Deacon , Linux Kernel Mailing List , Linux-MM , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , Vinayak Menon , Android Kernel Team Content-Type: text/plain; charset="UTF-8" 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: I was going to just apply this patch, because I like it so much, but then I decided to take one last look, and: On Sat, Dec 26, 2020 at 12:43 PM Kirill A. Shutemov wrote: > > +static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) > +{ > + struct mm_struct *mm = vmf->vma->vm_mm; > + > + /* Huge page is mapped? No need to proceed. */ > + if (pmd_trans_huge(*vmf->pmd)) > + return true; doesn't this cause us to leak a locked page? I get the feeling that every single "return true" case here should always unlock the page and - with the exception of a successful do_set_pmd() - do a "put_page()". Which kind of argues that we should just do it in the caller (and get an extra ref in the do_set_pmd() case, so that the caller can always do if (filemap_map_pmd(..)) { unlock_page(page); put_page(page); rcu_read_unlock(); return; } andf then there are no odd cases inside that filemap_map_pmd() function. Hmm? Other than that, I really find it all much more legible. Of course, if I'm wrong about the above, that just proves that I'm missing something and it wasn't so legible after all.. Linus