From patchwork Mon Jan 31 16:02:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12730829 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 B5930C433F5 for ; Mon, 31 Jan 2022 16:04:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19C636B00C5; Mon, 31 Jan 2022 11:04:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17DF88D0001; Mon, 31 Jan 2022 11:04:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03B236B00C8; Mon, 31 Jan 2022 11:04:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id E848E6B00C5 for ; Mon, 31 Jan 2022 11:04:27 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A457318216AE7 for ; Mon, 31 Jan 2022 16:04:27 +0000 (UTC) X-FDA: 79091054574.07.84A0309 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf18.hostedemail.com (Postfix) with ESMTP id 081631C000F for ; Mon, 31 Jan 2022 16:04:25 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id qe6-20020a17090b4f8600b001b7aaad65b9so8165427pjb.2 for ; Mon, 31 Jan 2022 08:04:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gisX+SmHlGPaod6BmlULNl1QqGpeThEpw2gv3Ed6fPs=; b=5Kju0dWpSHwXhYEWvUiml8KB/0ZMWI8SxY+Qz6NYPYq89/Rcn6kjtmlsEGtAmVwJoV 7UHjH692hPcUl3swiilP52F9+cY+ioBqdsilrfv8fyAr3nyRomOfaJ0DgIobtvOYXmHa xLVYYwa1pYNhqIDLyrj0GVbQc089q2E3TI/YbhKZr3Nuv66N5mnCSnrH1ZEbKxM/KuF/ 8m3792ODuO8Q2a+VlrTtC4n0FkTsRVP7BJ8Fy1Xj7Z0KimoGrsiJHh9CIAD4fClr/mi0 a7ZMNNBfQr2jcIC63VZUkaEmE2I8HeG3ec7oLHCYwwu/Srwvs59VWyFub+A/ec54/yny 4qxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gisX+SmHlGPaod6BmlULNl1QqGpeThEpw2gv3Ed6fPs=; b=H+bVR7D/3Ww5ogWWWCID3utMduQ8BKqfRncMX2nkgJknhhPk9vD8GNF+kJPO7lFHli 98wKFTKys+DySMeZr+oBfD4gTbWDTkainHvQfutC6Px+fmHQLIBmtyhAmeWot5mNCPTw Wo4gqbO/b62XTc+qKw/n7aPtmjc1hxV9pg+Ejb+xGz/soFaVFOUXE0u02z+V8aQngZxj TB/C1abUGeVS/yJVEyehVrADr4afDYb6SrLnPcSK5Net7CXDBCvj1vkShYokA9fKgyiC h86150VfP7xgczo7vRdhRpQNnvYA7xy34iKFgV30sOuMIfieUneuPfkwKyCbijPhKFrD QCcw== X-Gm-Message-State: AOAM5336F2m+FolDy5w9EcFlHbA9MzR4P0DfXSq6KrJ01YJfHWHiosC8 swqJYsEPwaKR1hoPggRIDaqcZg== X-Google-Smtp-Source: ABdhPJwnOHSIH/tVeMiDIsL5x0suj1BcB23ljOBPvIUrK1xrla1SShg+QsGbaZcLU6k68TnfcGxnWQ== X-Received: by 2002:a17:902:d2cf:: with SMTP id n15mr20697725plc.33.1643645065059; Mon, 31 Jan 2022 08:04:25 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id n42sm17940716pfv.29.2022.01.31.08.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 08:04:24 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com, rientjes@google.com, lars.persson@axis.com, mike.kravetz@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v3 5/5] mm: replace multiple dcache flush with flush_dcache_folio() Date: Tue, 1 Feb 2022 00:02:54 +0800 Message-Id: <20220131160254.43211-6-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220131160254.43211-1-songmuchun@bytedance.com> References: <20220131160254.43211-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=5Kju0dWp; spf=pass (imf18.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: nil X-Rspamd-Queue-Id: 081631C000F X-Stat-Signature: 1fwoc3tk9uqbdn1ocss6bhj37xepreff X-Rspamd-Server: rspam12 X-HE-Tag: 1643645065-327766 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: Simplify the code by using flush_dcache_folio(). Signed-off-by: Muchun Song --- mm/hugetlb.c | 6 +----- mm/migrate.c | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f1f1ab31dc8a..828240aee3f9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5804,8 +5804,6 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, goto out; } } else { - int i, nr; - if (vm_shared && hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) { put_page(*pagep); @@ -5821,9 +5819,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, goto out; } folio_copy(page_folio(page), page_folio(*pagep)); - nr = compound_nr(page); - for (i = 0; i < nr; i++) - flush_dcache_page(page + i); + flush_dcache_folio(page_folio(page)); put_page(*pagep); *pagep = NULL; } diff --git a/mm/migrate.c b/mm/migrate.c index c418e8d92b9c..daf2b3508670 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -933,12 +933,8 @@ static int move_to_new_page(struct page *newpage, struct page *page, if (!PageMappingFlags(page)) page->mapping = NULL; - if (likely(!is_zone_device_page(newpage))) { - int i, nr = compound_nr(newpage); - - for (i = 0; i < nr; i++) - flush_dcache_page(newpage + i); - } + if (likely(!is_zone_device_page(newpage))) + flush_dcache_folio(page_folio(newpage)); } out: return rc;