From patchwork Fri Jun 9 01:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13273074 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 3EFA1C7EE25 for ; Fri, 9 Jun 2023 01:20:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D16868E0002; Thu, 8 Jun 2023 21:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC6ED8E0001; Thu, 8 Jun 2023 21:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8F8C8E0002; Thu, 8 Jun 2023 21:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A9A258E0001 for ; Thu, 8 Jun 2023 21:20:11 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7AF5BA03B3 for ; Fri, 9 Jun 2023 01:20:11 +0000 (UTC) X-FDA: 80881453422.20.6DCB3C5 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) by imf21.hostedemail.com (Postfix) with ESMTP id B113B1C0006 for ; Fri, 9 Jun 2023 01:20:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=sbrAsg5W; spf=pass (imf21.hostedemail.com: domain of hughd@google.com designates 209.85.128.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686273609; 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=W3t6elq9R4Rh1GonIcnIp9HMVNr0t0fb96tM78h+6lY=; b=DGccTWVTMZZx10UV1Pz2j2KI7JdcOmW3UUHzD9aVwCHlWsdIneo62JW3OdTOhuF8MPskh/ p0/AvTU2O4KNmysnFC6GW0JArXBDkDccGWGMaOEiWpLAUeL/nSOfwQVfr08mZh44TPexfp iFxyFf1fZK6HzlCNbYWNn+B/fvucFcs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686273609; a=rsa-sha256; cv=none; b=zLyRegngnWyFkGiCtqa2Q/qMLjS4cq9qyq/UsQ3edgt/hcBYyXAteSXJGCv5JmOXut7CUE tl3b7J2SSD+ADRVUwHA73hKk0TWmrQval08uRob23sq9m906zf5Pr43wYGrzrd9Ty40Eem /05FlvL/wxKKREiziuP8ezfAurLwcUk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=sbrAsg5W; spf=pass (imf21.hostedemail.com: domain of hughd@google.com designates 209.85.128.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5664b14966bso11243037b3.1 for ; Thu, 08 Jun 2023 18:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686273609; x=1688865609; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=W3t6elq9R4Rh1GonIcnIp9HMVNr0t0fb96tM78h+6lY=; b=sbrAsg5WUYRFtaZIknvbQiG6/TYzlsI+0wgQgiUfJThncdOkuzQD0khSKs1V9z07r2 Tv51pW/PAoavvTS97xjUmu8LWWg94YJvp9vB5pfhhczalF5/DDl+Uv7HP4vGiWYqNo4X NvPImQC1dON//ZIIaJuY80thsOcoTmEarD24++KqimOdduTFWASKv9w7+mCL83HP6Bjj lCLJbqulD5C8g370KMX/kus7X70GOqLQ+qmTon2m/00V/c4ahLqm0Dsyh/zh31jb7WvE PrxBXcgSpFRmWGUOtPIfuBbXHPk/T7GjZ0IZtugAqqqNtfJYQbkhOVtUktXosevWE1uY kB2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686273609; x=1688865609; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W3t6elq9R4Rh1GonIcnIp9HMVNr0t0fb96tM78h+6lY=; b=d0ydeb6jb17LrUQUKfc8tIkr/f+0CbtSRvkfiyJTxIGhwHUM8Rx6igwYOUZ3KygEKa B3xhvnaZha8ljiqio+bWtDkN0Kyxt49w6KOr9LKwtUNMzlUP4F9HY3A6UucVE+T/dvXb zaPgUc7dmHG1S9uV4P4MFpmtO8T2YqfKfhfvhMRCY/zCDNXz9XXeNtVxIFoKhi+yQ1wx +XrxEaMTtxE+odEXZlfVzoBpn0LuS/TRAIG10opnqfBp/R6XCXc52m3JjGYqO9s0N0Bn GYbA7X4vn+Ed16B7DwQX30tn64a0AHtD03Ypmkne5JRGLc66Vk5qqqlrGqKF7dbfzEXg tLqg== X-Gm-Message-State: AC+VfDwUM9EOyvw7QCu7/IM4Yggz/5aH85mWVc82na96OmaXe1SDku+S T2c1TXjVZcnZP4qClB8c8lLN0Q== X-Google-Smtp-Source: ACHHUZ6n8W5YFW3Tw+jdRjglpr2r72K5tunXYPvH/mLAwhgJM3++HeY9qf1iqDSmIO6b6XIA/ifN5Q== X-Received: by 2002:a0d:dd01:0:b0:568:b0f6:ce8a with SMTP id g1-20020a0ddd01000000b00568b0f6ce8amr1205033ywe.24.1686273608570; Thu, 08 Jun 2023 18:20:08 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id j77-20020a819250000000b00565862c5e90sm289860ywg.83.2023.06.08.18.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 18:20:07 -0700 (PDT) Date: Thu, 8 Jun 2023 18:20:04 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 11/32] mm/vmwgfx: simplify pmd & pud mapping dirty helpers In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: B113B1C0006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: u49q5kg356i1zg5ca5ih7j17fi7u9u6g X-HE-Tag: 1686273609-832115 X-HE-Meta: U2FsdGVkX1/ovSjY2usCjNeKbqbBEDye31Qq+O7vfou0jm1m0jzv/a6jyW1WuOjpe5P3Wg4Rel++DZ+tRIIccaLmWriqLHlMCYX2tfumyr0ETgnK2QiIVvTaWjSZvIA+BRFDJIs4yReYrcy+oeVLAJrieRbhpZP9py5bAAXy2Nd1gtMGAc4sJVCN0JyLHXiQN2EV/BytLjvEsjhD+UFAuaKpDuyxx7iwR9n2k/WybYAB49Bx99ya5RfM1EIAR0Gtbck1VbcRAIng/DJ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aveG1n8kdZcSotoy73DuufMBP1 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: wp_clean_pmd_entry() need not check pmd_trans_unstable() or pmd_none(), wp_clean_pud_entry() need not check pud_trans_unstable() or pud_none(): it's just the ACTION_CONTINUE when trans_huge or devmap that's needed to prevent splitting, and we're hoping to remove pmd_trans_unstable(). Is that PUD #ifdef necessary? Maybe some configs are missing a stub. Signed-off-by: Hugh Dickins --- mm/mapping_dirty_helpers.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/mm/mapping_dirty_helpers.c b/mm/mapping_dirty_helpers.c index e1eb33f49059..87b4beeda4fa 100644 --- a/mm/mapping_dirty_helpers.c +++ b/mm/mapping_dirty_helpers.c @@ -128,19 +128,11 @@ static int wp_clean_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long end, { pmd_t pmdval = pmdp_get_lockless(pmd); - if (!pmd_trans_unstable(&pmdval)) - return 0; - - if (pmd_none(pmdval)) { - walk->action = ACTION_AGAIN; - return 0; - } - - /* Huge pmd, present or migrated */ - walk->action = ACTION_CONTINUE; - if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) + /* Do not split a huge pmd, present or migrated */ + if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) { WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval)); - + walk->action = ACTION_CONTINUE; + } return 0; } @@ -156,23 +148,15 @@ static int wp_clean_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long end, static int wp_clean_pud_entry(pud_t *pud, unsigned long addr, unsigned long end, struct mm_walk *walk) { +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD pud_t pudval = READ_ONCE(*pud); - if (!pud_trans_unstable(&pudval)) - return 0; - - if (pud_none(pudval)) { - walk->action = ACTION_AGAIN; - return 0; - } - -#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD - /* Huge pud */ - walk->action = ACTION_CONTINUE; - if (pud_trans_huge(pudval) || pud_devmap(pudval)) + /* Do not split a huge pud */ + if (pud_trans_huge(pudval) || pud_devmap(pudval)) { WARN_ON(pud_write(pudval) || pud_dirty(pudval)); + walk->action = ACTION_CONTINUE; + } #endif - return 0; }