Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4800705pxb; Tue, 5 Oct 2021 10:34:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytYiemKA0Q8YsuwXSzB4i9HgMkyjJtZx7yoGwqg5PG3rLUYTkJKIET7dewt19jnbop4Psh X-Received: by 2002:a17:90b:4a81:: with SMTP id lp1mr5349829pjb.124.1633455280389; Tue, 05 Oct 2021 10:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633455280; cv=none; d=google.com; s=arc-20160816; b=C62U0uUh7QBKR67gVKhXMOShSxHOf4Ne/gVuKYIEJeZrrFoUFaCuIzy3nIE8Z2nHmu kpuuIdSg5RIqpigh9B6PHb+CxWmNgsRCidI+ErBbFb4Auz1S8X5XgkPrxSh7RopNOuDS nLm2IuNie8VSZNkmQaeKZaenXw7GpKpnPFo0cbYb5Woj7DtwrsEpmFRKeGZfEb9+YSOr oZA4FELeaNHRHfYyrd6+DFz51rVfPWugMXxEzHNBgPxl0IgaIK4pn+F2Ri3uRkZMV2iw jnBxUZB09yCvSoBHaCdKwFE/SnFC+pwnc0Pla5W8C69d/Q/a1HQV2vO29mGGRYiFtAW4 B7eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=DGNbaD457msJgVdKh0PPRgk92evjmql7WYFpgopbLNQ=; b=Onfc4LicBoImf4gpfbpeQFd6R73M/ng+yDzW5gItQrypJ/EYbwZ3qs2phXQhhiGRKp KI0AcHyIdORteUi3FDRz9PIUR52GEVOBWU2dGXCRopzCw5x1yifuycf96m/JltGTfnyQ Vq4iFF42TjTRBmZmAX9AUMoyQX8U87nO3kI+E/jhf3xIwfNi1Ir1LfpqH8LaheF5vwmv 94z0yeYa3/dsWljI6M57lKg5y/TXRhQqE9Z0AuoC0a4RVQaH+2nk7zjU6xsRcuUkdTcs cWdm0uLfaajDTIeYQfqVtHv7es7bQ5EuZLYiNlCDQOvVaf0AEHuR7EQ/jfjINT8ic6Zt HWRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hF0f9dNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v62si23838803pgd.360.2021.10.05.10.34.26; Tue, 05 Oct 2021 10:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hF0f9dNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbhJERez (ORCPT + 99 others); Tue, 5 Oct 2021 13:34:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43017 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234144AbhJERey (ORCPT ); Tue, 5 Oct 2021 13:34:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633455182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DGNbaD457msJgVdKh0PPRgk92evjmql7WYFpgopbLNQ=; b=hF0f9dNzShk22Hh9oLXt22JYDKTmSvG79SXn43/ZhCHHDEBSMvDemJVFumpsLYbVz56LgU TcG5QOcriy5tcZfDvu/WvTVI9PjDCtyliWdNAHrYdsWcu9l0K+84ETYVWa+NriGUk1S/3U xt3OkguNsMsIuDkN6UPCv34Rpv7zMro= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-P4B_ILwbNJGqRPQSmvcqeQ-1; Tue, 05 Oct 2021 13:33:01 -0400 X-MC-Unique: P4B_ILwbNJGqRPQSmvcqeQ-1 Received: by mail-wm1-f70.google.com with SMTP id 10-20020a05600c240a00b0030d403f24e2so1595069wmp.9 for ; Tue, 05 Oct 2021 10:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=DGNbaD457msJgVdKh0PPRgk92evjmql7WYFpgopbLNQ=; b=etdmqmiCiFu2OudbpGdyAot9Dv2B0HFKe5RAQQWV5bRsfnFrGADp7ugEp0w4sqaozv SqQYv2b07DEOHZTh+X9ywJeWqYIZ9vt3CXgwn9JsWA9U0C2J54aSDf6/T7naEmtFFv3i JXI5jzOfmjd4eN+FYw/Io/I1hhhKh/FETPBeXgcZLuwlg4O0NPPHYOD+rXNrURfo6AvQ Uqlr/9ELE6mtWZqdRDLyBbSgDf47LYgSvF3vgA2wDhjH9zjzpci6y0ZlCv8XadglyExD 7PAYj3L/CBrL6sKNX2H0zE/eza2FoOFDl+CwClfbPhDIJPJ/Gm7JN/l+7sRuMyL7np6k E5aA== X-Gm-Message-State: AOAM533K6kg4w+Hq4jXO1TZXJmaWNNZbTXx0CdJDc0mJnO/tae6q0a6C 9ghYPUgNUt87kNZCekVh4tvi1ckAJ54g5cKBjAJrylIlTZm7PBebeXwoyI01vL6ezwYzl656GXZ eZMBvfLAJUocnhyV9U0B58+Od X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr4937367wmq.154.1633455180714; Tue, 05 Oct 2021 10:33:00 -0700 (PDT) X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr4937342wmq.154.1633455180492; Tue, 05 Oct 2021 10:33:00 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6741.dip0.t-ipconnect.de. [91.12.103.65]) by smtp.gmail.com with ESMTPSA id o3sm18358930wra.52.2021.10.05.10.32.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 10:33:00 -0700 (PDT) Subject: Re: [GIT PULL] Memory folios for v5.15 To: Johannes Weiner , Matthew Wilcox Cc: Linus Torvalds , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton References: From: David Hildenbrand Organization: Red Hat Message-ID: Date: Tue, 5 Oct 2021 19:32:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.10.21 19:29, Johannes Weiner wrote: > On Tue, Oct 05, 2021 at 02:52:01PM +0100, Matthew Wilcox wrote: >> On Mon, Aug 23, 2021 at 05:26:41PM -0400, Johannes Weiner wrote: >>> One one hand, the ambition appears to substitute folio for everything >>> that could be a base page or a compound page even inside core MM >>> code. Since there are very few places in the MM code that expressly >>> deal with tail pages in the first place, this amounts to a conversion >>> of most MM code - including the LRU management, reclaim, rmap, >>> migrate, swap, page fault code etc. - away from "the page". >>> >>> However, this far exceeds the goal of a better mm-fs interface. And >>> the value proposition of a full MM-internal conversion, including >>> e.g. the less exposed anon page handling, is much more nebulous. It's >>> been proposed to leave anon pages out, but IMO to keep that direction >>> maintainable, the folio would have to be translated to a page quite >>> early when entering MM code, rather than propagating it inward, in >>> order to avoid huge, massively overlapping page and folio APIs. >> >> Here's an example where our current confusion between "any page" >> and "head page" at least produces confusing behaviour, if not an >> outright bug, isolate_migratepages_block(): >> >> page = pfn_to_page(low_pfn); >> ... >> if (PageCompound(page) && !cc->alloc_contig) { >> const unsigned int order = compound_order(page); >> >> if (likely(order < MAX_ORDER)) >> low_pfn += (1UL << order) - 1; >> goto isolate_fail; >> } >> >> compound_order() does not expect a tail page; it returns 0 unless it's >> a head page. I think what we actually want to do here is: >> >> if (!cc->alloc_contig) { >> struct page *head = compound_head(page); >> if (PageHead(head)) { >> const unsigned int order = compound_order(head); >> >> low_pfn |= (1UL << order) - 1; >> goto isolate_fail; >> } >> } >> >> Not earth-shattering; not even necessarily a bug. But it's an example >> of the way the code reads is different from how the code is executed, >> and that's potentially dangerous. Having a different type for tail >> and not-tail pages prevents the muddy thinking that can lead to >> tail pages being passed to compound_order(). > > Thanks for digging this up. I agree the second version is much better. > > My question is still whether the extensive folio whitelisting of > everybody else is the best way to bring those codepaths to light. > > The above isn't totally random. That code is a pfn walker which > translates from the basepage address space to an ambiguous struct page > object. There are more of those, but we can easily identify them: all > uses of pfn_to_page() and virt_to_page() indicate that the code needs > an audit for how exactly they're using the returned page. +pfn_to_online_page() -- Thanks, David / dhildenb