From patchwork Thu Jan 5 10:18:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 39443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp227773wrt; Thu, 5 Jan 2023 02:22:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLnPlwxKQx20ABj5KlqPIOMJxtpDlJPxEnDeDh6DfHQX9bv6DROG1qVsfueZFZw1nTflVT X-Received: by 2002:a05:6a20:6f47:b0:a3:7d0b:5dcb with SMTP id gu7-20020a056a206f4700b000a37d0b5dcbmr64532986pzb.15.1672914166538; Thu, 05 Jan 2023 02:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672914166; cv=none; d=google.com; s=arc-20160816; b=GhzYUM3o0puZQGglZddsTIY/VUBK3spShooh6oe1a1qvkUduk2MvFhKyfV8Gz+mH7N LhfpJrKcFYv27ZbtEIylA8dj1PHb5AW0fKT3rOKdsCI39j6FNPxh0xS4N2yeM94Ivdea mr2vDP3Jo0jLrojt1bix+Fs3c59310L8lmFpRCjSQpgUuWY7DC+45ZlLfdahhxE1biOZ YN8qnfHP2/rPjqLhNdK41FLIMDvtzZ7hbCHNbZJdtZiERW0P4Utbk1+7afa/YW/OmMSR alDgFEnQfWQ7bf9PasBBiE6wtkQuAFOLAY9gtG/hm2r0NJKtjEj7xQCawnukoIUe189b 51Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=nuChqEE6EgS9ZWad0RFM9vhCC4fCrQA1CHpyknS9e9I=; b=Horn6Pk7HWUeQmBeZZC1CXTV4/hTfvybRk8B58CpjDlrOaAZvVfIEnBIhrXpBNuEYM z8biuklAE58sxxruBuzBVYp+16uQghh7P4eNwekMBEbd8ur5MGp90bkkursn1ICcyoAc LcM+u+OpF53SfxskGeWgQJIfDxBvUSPszEUbqyMcL8VB/gXSvn0E0HT/TV++a1fc0/a6 UhCmUc87tA+5+t9SYHC3YEquPImYlo9PGk3+xv2xi96oAw51P7Ijg6y6x80bFVKQA8J6 TXt608nr3wYmEYcyQBcP2CGSkLNzvGtIxyR+lUk4Dw6sdHurIlkOgMgdnNqwFcBo51YL ohJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PMdoUglm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w190-20020a6382c7000000b004a418549e70si8552100pgd.239.2023.01.05.02.22.34; Thu, 05 Jan 2023 02:22:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PMdoUglm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232959AbjAEKVe (ORCPT + 99 others); Thu, 5 Jan 2023 05:21:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjAEKT6 (ORCPT ); Thu, 5 Jan 2023 05:19:58 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C680559DC for ; Thu, 5 Jan 2023 02:19:27 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id t13-20020a056902018d00b0074747131938so36503864ybh.12 for ; Thu, 05 Jan 2023 02:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nuChqEE6EgS9ZWad0RFM9vhCC4fCrQA1CHpyknS9e9I=; b=PMdoUglmYM3qm6mWAqtyVJgzu77MRJxWmvYG3y/y52hzYvzk3AeSDZU/v2V/pwhi1f AihoMvQwpu8u1lszjJmu97VBPUPHphQwGK+Wi8ukPijxmNbY6TtoExxE1zmWstSCaeED T5Ii9p6OfjRqSgGbZeKD1Y0Rzcm0Fdvj3xukaysFr/AEQaLMJgbLYNRWvM54l3lHDA7x fl11csrpr58Kd28oGSDnxgd7q6xGmGLlKrMpRBTnVtv5V+fe2oSKpXRf+O+a4IQLcoCC PuKdMBIByP3sRXz/ggMAPuiyizC3+IXS18St1U3mOWfSpY1iHbA15ZXf/yxY1pQexB6C posA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nuChqEE6EgS9ZWad0RFM9vhCC4fCrQA1CHpyknS9e9I=; b=2yp3XvOgcjrMUSjDXZFOBefclY0cZNlvGSMBU+biuX8yV2OVnWVjWtlh1ZrZ2K8Tw5 DZYyZVzmDl+VFMWmRRXAv0VIoBMHEYiJyboXLQBBId35FuwZF64wSpec2+/gUxBxj3kl gKZqLL2egqzImWqNDConQDQsEoMXY/8AO4wMGQK+r5OAeNQZPmj88shUNoBKbySV08/U LEsXazUie5BMHuRoa8LRNGAE76rihzq5/zko+7ufuptrsan70UvdzeI4PxLgLACk4QR0 2DxUBfWMGxt19VpDFaqYkKNLBkJZrrjEpuP26o4tomXOePevI20FwL2vwLa3MP4THiZx n93g== X-Gm-Message-State: AFqh2koxNadWcFQL9CE5i4EBhPXIDX4ubPftqoCDiJ1J8/bj7DKXVJpN AbqRYgy+YDFuk4grrFgUWHPdNWtTJ8T/lkpi X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:688a:0:b0:3b7:e501:90cf with SMTP id d132-20020a81688a000000b003b7e50190cfmr2167304ywc.501.1672913967234; Thu, 05 Jan 2023 02:19:27 -0800 (PST) Date: Thu, 5 Jan 2023 10:18:20 +0000 In-Reply-To: <20230105101844.1893104-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230105101844.1893104-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230105101844.1893104-23-jthoughton@google.com> Subject: [PATCH 22/46] mm: rmap: provide pte_order in page_vma_mapped_walk From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , "Zach O'Keefe" , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754177645092863987?= X-GMAIL-MSGID: =?utf-8?q?1754177645092863987?= page_vma_mapped_walk callers will need this information to know how HugeTLB pages are mapped. pte_order only applies if pte is not NULL. Signed-off-by: James Houghton --- include/linux/rmap.h | 1 + mm/page_vma_mapped.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index bd3504d11b15..e0557ede2951 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -378,6 +378,7 @@ struct page_vma_mapped_walk { pmd_t *pmd; pte_t *pte; spinlock_t *ptl; + unsigned int pte_order; unsigned int flags; }; diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 4e448cfbc6ef..08295b122ad6 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -16,6 +16,7 @@ static inline bool not_found(struct page_vma_mapped_walk *pvmw) static bool map_pte(struct page_vma_mapped_walk *pvmw) { pvmw->pte = pte_offset_map(pvmw->pmd, pvmw->address); + pvmw->pte_order = 0; if (!(pvmw->flags & PVMW_SYNC)) { if (pvmw->flags & PVMW_MIGRATION) { if (!is_swap_pte(*pvmw->pte)) @@ -177,6 +178,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (!pvmw->pte) return false; + pvmw->pte_order = huge_page_order(hstate); pvmw->ptl = huge_pte_lock(hstate, mm, pvmw->pte); if (!check_pte(pvmw)) return not_found(pvmw); @@ -272,6 +274,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) } pte_unmap(pvmw->pte); pvmw->pte = NULL; + pvmw->pte_order = 0; goto restart; } pvmw->pte++;