Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6541254rwi; Mon, 24 Oct 2022 02:51:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/COPFfe9f5mmTgQ6q77sTyc4/BldW0j+YfF0F3a1AH94UojZ5zKMoi5XCx0f9vAfnmC0Z X-Received: by 2002:a63:7704:0:b0:464:3985:8963 with SMTP id s4-20020a637704000000b0046439858963mr28345148pgc.154.1666605095787; Mon, 24 Oct 2022 02:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666605095; cv=none; d=google.com; s=arc-20160816; b=LSftLKHo+lkOnknaZEuUIF3EZkfhEAUGlpK/O0uBCBUz8GFm2lKR0lt0dx/OBe9Hez WeNn5zfSZ0btG/5Q3o5+K/RgsctFH6NryVCgEjAvissB3kDUpWeS8GYGhiNEQx+9LpJf FudFkSiOexr2VmqFEs5llb168dOrbbkEsgOZTIg/acmHFvJ68s/tqWASPDZ1z6hMf6bR XxlH4K+0REG35S3+avYY2wxkUg8scHg/X55bJLXYsAGWlMM4PhA3UjmWvnUCHPs+Y5Mk +/1hbOoZbgUnZfxzhDzYE9OjuaNzZ3l3oCJwq+EPWlU1uErXc2KBL18DLExFANJePi6K nbFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WxlvJtokl8CIIx1nHH00BhDjUl5xmlqOmMKx2xT/NS8=; b=V+v4Ohsk8J3rruTiJ9+qUSLgnAX/3T3WYaL0ZVgrhTzPLON/evVR+E22PCrXVZeNJq rvNRSlGNHmuaGEKobaBU+0//olRlGPXSd4MWtqBk4v1Mr7Tl2Dwf0xTZQ/kPWL8+UrS/ mNGqjyLEvCOIviIhBaRs+CaPx7sSIrl/g7L033nwBRuq/V5l/kzgrAxRxYKQukzxXERT JzWiPnji3YN5B9Zbz5RjVSwYHKyImw5zMORLxnCcP7N5KUV3mqxdkqauuuTsiyTLItwj OcbaPFujmzrq6qop4nL98dK1PuAH9RQ/nvCMSwaWqMn8m9uWNNFcChHFImzBp4eg/bEp sqXQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k62-20020a17090a4cc400b00212d5631badsi7848106pjh.55.2022.10.24.02.51.23; Mon, 24 Oct 2022 02:51:35 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbiJXJVz (ORCPT + 99 others); Mon, 24 Oct 2022 05:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbiJXJVr (ORCPT ); Mon, 24 Oct 2022 05:21:47 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE5558EBF for ; Mon, 24 Oct 2022 02:21:45 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MwqJM5NTWzJn9s; Mon, 24 Oct 2022 17:18:59 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 17:21:44 +0800 Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 24 Oct 2022 17:21:43 +0800 From: Tong Tiangen To: Paul Walmsley , Palmer Dabbelt , Albert Ou CC: , , "Tong Tiangen" , , Guohanjun Subject: [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page Date: Mon, 24 Oct 2022 09:47:24 +0000 Message-ID: <20221024094725.3054311-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024094725.3054311-1-tongtiangen@huawei.com> References: <20221024094725.3054311-1-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 HugeTLB pages are always fully mapped, so only setting head page's PG_dcache_clean flag is enough. This refers to the following link: https://lore.kernel.org/lkml/20220331065640.5777-2-songmuchun@bytedance.com/ Signed-off-by: Tong Tiangen --- arch/riscv/include/asm/cacheflush.h | 7 +++++++ arch/riscv/mm/cacheflush.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index 8a5c246b0a21..c172d05de474 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -17,6 +17,13 @@ static inline void local_flush_icache_all(void) static inline void flush_dcache_page(struct page *page) { + /* + * HugeTLB pages are always fully mapped and only head page will be + * set PG_dcache_clean (see comments in flush_icache_pte()). + */ + if (PageHuge(page)) + page = compound_head(page); + if (test_bit(PG_dcache_clean, &page->flags)) clear_bit(PG_dcache_clean, &page->flags); } diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 6cb7d96ad9c7..062559c04fc3 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -82,6 +82,13 @@ void flush_icache_pte(pte_t pte) { struct page *page = pte_page(pte); + /* + * HugeTLB pages are always fully mapped, so only setting head page's + * PG_dcache_clean flag is enough. + */ + if (PageHuge(page)) + page = compound_head(page); + if (!test_and_set_bit(PG_dcache_clean, &page->flags)) flush_icache_all(); } -- 2.25.1