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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F2D9EE4996 for ; Mon, 21 Aug 2023 16:48:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10A5E8E0002; Mon, 21 Aug 2023 12:48:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BC576B0085; Mon, 21 Aug 2023 12:48:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E238E0002; Mon, 21 Aug 2023 12:48:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D92586B0083 for ; Mon, 21 Aug 2023 12:48:24 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AFAC740CB5 for ; Mon, 21 Aug 2023 16:48:24 +0000 (UTC) X-FDA: 81148694928.02.D9F2831 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 9D3F9140037 for ; Mon, 21 Aug 2023 16:48:22 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RAhkHPDC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692636502; a=rsa-sha256; cv=none; b=U8EnO2eYyXz/mzshQfBZ5QWb/5VWk/eASIL0psYKqWaYHnSKs9rLJNEqHIaHIrSxxVsw/7 i1NhlIX/7m2Ss4HpN9U8tgaqiuTr6QYkySTlRAyqxf0bJWuLbX9TsnCYK2687EwiHy973D nqn2wABmZKNW52AEyYHpV//JwQSAv0M= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RAhkHPDC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692636502; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FfO9iw8ZrQkMAkZ0ZI6xh3gNXetrFGiLWgqaCN9zzcI=; b=SzUtvm5mTs/MBuYj40P0FE8tUweMEZ3+nWqfNNlZXRk+M5UAU/dH7f+WrbgttyD9mXOQwr r+D4AbT02ckudlLlZPkEIPJGSylkc8IMq2U7y1GHsswYf1Vuu7qItcs03gzfy7+ns520DJ 2L1waHtvKB9tv2Lki92SBoj6fLF50LY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692636502; 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: in-reply-to:in-reply-to:references:references; bh=FfO9iw8ZrQkMAkZ0ZI6xh3gNXetrFGiLWgqaCN9zzcI=; b=RAhkHPDCl/f1k/Zs3rKylApoG3orFux0Yb+QduwnxMv2XK/w8hrPNBbvLQfe5ZrLD0beld u1UYg6CW2B8oEzOY34AVeQDbx8DM/0350uVxsIx7jmZ+Idcgvud2t6XEmMVLm6hVMq7Rtm T3cDESGiykJNIuvtMyEfxDQfCXFZemM= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-AWd9-YuyPhu372LpdX6PmQ-1; Mon, 21 Aug 2023 12:48:20 -0400 X-MC-Unique: AWd9-YuyPhu372LpdX6PmQ-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-76cb292df12so129145985a.0 for ; Mon, 21 Aug 2023 09:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692636500; x=1693241300; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FfO9iw8ZrQkMAkZ0ZI6xh3gNXetrFGiLWgqaCN9zzcI=; b=e+ilwpUqDozqn9rCcyruf/gq6PRPgHgW0HgsjSu8W+4YjWOqTkIfZJ6q6njdk4oiIB ezNxUIe1eKKaR2R1S/JItPrlRVi/QkEWHVlW9FacEFosFNeAlFSlAh/wbb0i1AWPHrwr fj+jmmnkYz9svM8d6jTmHycxsQJQT4rq1HaNcclpKVx7gVFeque2DaxFWleVERG+YSgA Q7fwzhapOhmZfFWY5u1FVqF5rvqhpybn3LzrVUhZygHYWsBKykzfA+iE0y28GWn7HedN IxyULp5zDfrD3yBaj9QGouFA3N+vtmw79Aujv95iwwB5GrqM+bjcK0kIXPXAxHqLyq/B OSQQ== X-Gm-Message-State: AOJu0YxFdPKYxn0tzKsBf8KPJIE2g00Yxu4MzvcqTc5LSigkIhzNIlan NIzNyitMm07khkYPZ0RQoRTG6nfA8dtG10LGC9ikLj704oD0pRabD59SlpZMDADlIOu24oL8oTX x5QXRSPOlhwg= X-Received: by 2002:a05:620a:1a1c:b0:76d:95d3:800f with SMTP id bk28-20020a05620a1a1c00b0076d95d3800fmr9787867qkb.3.1692636500233; Mon, 21 Aug 2023 09:48:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgc1yyExO/s4EFGIm8G5RpBPVJ+Kir8Jj4F40Wb4rI0lKlydsyKeJCPBf2UbuvMaXVgJ0CpA== X-Received: by 2002:a05:620a:1a1c:b0:76d:95d3:800f with SMTP id bk28-20020a05620a1a1c00b0076d95d3800fmr9787854qkb.3.1692636499934; Mon, 21 Aug 2023 09:48:19 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id h27-20020a05620a10bb00b0076cda7eab11sm2566443qkk.133.2023.08.21.09.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 09:48:19 -0700 (PDT) Date: Mon, 21 Aug 2023 12:48:18 -0400 From: Peter Xu To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yang Shi , Mike Kravetz , David Hildenbrand , "Kirill A . Shutemov" , Hugh Dickins , Andrew Morton Subject: Re: [PATCH] mm: Wire up tail page poisoning over ->mappings Message-ID: References: <20230815210659.430010-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9D3F9140037 X-Stat-Signature: ufaab3czr6oqcpabmx4dmq9qdbo8wcuf X-HE-Tag: 1692636502-896271 X-HE-Meta: U2FsdGVkX1+xS9kb0pR2a6APnq6Ke2q+oLKnV5rDShh2X7CVWCRJf/PIg6UEQ03TK23iE74RRO+fjTSRdjcCadwdDB7k4lgY57PayZLzh4ZK7sMex6G/pd3XtgJNKibfAH+rSj1Qry0cmDdwivRsMvdaaHzzUfbkX6NG5EjGnCzfZnrrf4iFx02LKcByXqDmkBYFEO2j+Tw1mkFjsk6SA3J4CTagHzH9t1bxqZBC2BYEiodZ5UPmAyZ/mhdLpE/3NA+abzKn6YKkJu5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GXU+5+xb1uMhJkMEUG2vbczTkCUhHUh0Zu9UY4LHG3h84ETjmD7zWjA1ulXCXbXlAshOd0gkJGhGdcKBxRJvAzP3tzFrWLnDExO6UO6gDuNCDuAErKL5m1CvAdW5 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 Mon, Aug 21, 2023 at 03:29:01AM +0100, Matthew Wilcox wrote: > On Sun, Aug 20, 2023 at 09:13:55PM -0400, Peter Xu wrote: > > > https://lore.kernel.org/linux-mm/ZNp7yUgUrIpILnXu@casper.infradead.org/ > > > > https://lore.kernel.org/linux-mm/ZNqFv0AwkfDKExiw@x1n/#t > > > > Firstly, I've answered and you didn't follow that up. > > I didn't see it. I get a lot of email ... > > > > > More importantly, I think this is over-parametrisation. If you start to > > > > use extra fields in struct folio, just change the code in page_alloc.c > > > > directly. > > > > Change the hard-coded "2"s in different functions? Can you kindly explain > > why can't we just have a macro to help? > > Because it's unnecessary. You're putting in way too much effort here > for something that might happen once. > > > Setting tail mapping for tail 1/2 is even wrong, which part of this patch > > fixes: > > > > @@ -428,7 +428,8 @@ static inline void prep_compound_tail(struct page *head, int tail_idx) > > { > > struct page *p = head + tail_idx; > > > > - p->mapping = TAIL_MAPPING; > > + if (tail_idx > TAIL_MAPPING_REUSED_MAX) > > + p->mapping = TAIL_MAPPING; > > set_compound_head(p, head); > > set_page_private(p, 0); > > } > > I didn't see this. This is wrong. tail->mapping is only reused for > large rmappable pages. It's not reused for other compound pages. Just to make sure we're on the same page: I think it's not only _deferred_list (of tail page 2) that reused the mapping field (word offset 3), but also _nr_pages_mapped (of tail page 1)? > > If you really insist on cleaning this up, the special casing of tail pages > should move out of page_alloc entirely. folio_undo_large_rmappable() > should restore TAIL_MAPPING for all tail pages that were modified by > folio_prep_large_rmappable(). > > The other thing we should do is verify that the additional large-rmap > fields have the correct values in folio_undo_large_rmappable(). > > But let's look back to why TAIL_MAPPING was introduced. Commit > 1c290f642101e poisoned tail->mapping to catch users which forgot to > call compound_head(). So we can actually remove TAIL_MAPPING entirely > if we get rid of page->mapping. > > You probably think that's an unattainable goal; there are something like > 340 occurrences of the string 'page->mapping' in the kernel right now > (and there are probably instances of struct page named something other > than 'page'), but a lot of those are actually in comments, which would > be my fault for not fixing them during folio conversions. > > However, I have a small patch series which enables 'allnoconfig' to > build after renaming page->mapping to page->_mapping. Aside from fs/ > there are *very* few places which look at page->mapping [1]. I'll post > that patch series tomorrow. Assuming it's still not yet posted; I can wait and read it. If you plan to remove the whole TAIL_MAPPING in a few days then I agree this patch is not needed, but so far I don't know when it'll land and also why, before that it does sound like we can still keep this patch. Regarding the question on "why removing TAIL_MAPPING": poisoning an unused field is always helpful to me even if not referenced with "page->mapping". So I don't see an immediate benefit from removing the poisoning if it's already there; OTOH not sure whether poison more unused fields will be more helpful in general? > > I think with some serious work, we can land "remove page->mapping" > (which would include removing TAIL_MAPPING) by the end of the year. > And that work gets us closer to the goal of shrinking struct page. > > [1] device-dax, intel_th, mthca, cortina, fb_defio Thanks, -- Peter Xu