Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4627915pxb; Tue, 5 Oct 2021 07:08:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzppKpms6fv79jqYiCrJtdbZRoWFID6q3NW2zcySu0Nyy9hPReOcaou58F+fwegipz29rHy X-Received: by 2002:a05:6a00:1826:b0:44b:e447:399c with SMTP id y38-20020a056a00182600b0044be447399cmr31752193pfa.59.1633442917919; Tue, 05 Oct 2021 07:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633442917; cv=none; d=google.com; s=arc-20160816; b=SodvDErgJXr1H7IS+adfPg+RIDQ6dmEP37eaMOte4dYuIpODk5dojcIll85QaJo8yA VMlpYvikcsG0E4GivapMKOJpeGDf1GUl4oDLwLlCj/MqdAs4HjbOedV0o+P2R0/VOqgk 62L5XyVtIzZnWNxSV9HRayNcXKdL2O6nOsvOi8RVYYsduyb09tdt9/hZCnptqRbXBoEP unbcGvvP0wdlQVSHIMZZ2P1GscZrK37Ffbl0kw9wkA+u5tKik/+EWuGhAgx/O1TNsVe0 FN4M6stykjAuWH+oJkFeoKrDCC5ZtflExmfjRHrB75VjfJX5hzFHdXzLDY9Z3l8I55at e8tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fPliqX+4y/fXYKkrPsdcJN5EsDLXmdXa3jrI3RxuZqo=; b=bLJ4mb9VH+t9OlznQuH7HZpjJ8rXeW0Nqk40lp6GU/VNfPMN2VlE5FzPe5OqfU+/AJ fbNmTB29+xo+H/WAVmhJEROcFgOh9MTVh+UQqLxRv2rZa8o6wVDfG6X1ezvu0jgNzcyw MWCc3+BHcwewJrN+UihuX7/xJVXoqizkt8oDalAziFT00vBuvAuee69jPZ3bFOXQZ8nV aVuV+8nGi0gWSPlwlVrJYC5cRQ56b8jdFBh7UrZqtlYjRfYvjm/xkXxeTlAUWk5+Sj3Y qt4l/MTI0+6slBbYiglFbRVp7pMnozGRB1eLbM/ZV84AN4MUzlHnISevFVTHlMemGugh r9mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HWNkq0kU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si2240100pjj.23.2021.10.05.07.08.21; Tue, 05 Oct 2021 07:08:37 -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=@infradead.org header.s=casper.20170209 header.b=HWNkq0kU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236340AbhJEOFH (ORCPT + 99 others); Tue, 5 Oct 2021 10:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235411AbhJEOEw (ORCPT ); Tue, 5 Oct 2021 10:04:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426DCC09427F; Tue, 5 Oct 2021 06:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=fPliqX+4y/fXYKkrPsdcJN5EsDLXmdXa3jrI3RxuZqo=; b=HWNkq0kUiHpUTPpZafcDeNnk43 lkwTkf/5ITfsDQOECQdIGNOHHYcRVdjV/7W4WGkVi9lmiM7NQkiG4vJL148Qg/kaLh1urI/5lFSy2 z5d2Ry0WkueUJLM80zgcGTQ9BR6Jr71tVs9UHjeHnn6YFLrEI9dApUnQVPajkltcj3+VWsvHNvGn7 kgkiPHsiY0DkUSROcMdMGdfYsDtu+8geX3OxcYJRpwtoEntkZf7c6vhTB+ww87EwDRgefqg0294kb 3Pv0wDaTD0pFucG/MuxqfjQedQMHHFECN2QrfQpzeTpsMzZgnbGKvc47H25ofF66k92entMll6Nbm OwCmf/dg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXkrR-000VHF-9k; Tue, 05 Oct 2021 13:52:41 +0000 Date: Tue, 5 Oct 2021 14:52:01 +0100 From: Matthew Wilcox To: Johannes Weiner Cc: Linus Torvalds , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [GIT PULL] Memory folios for v5.15 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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().