From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BFC5369355 for ; Thu, 21 Aug 2025 20:08:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755806890; cv=none; b=Ne0PHOuN1NMWrTiAusWCJxjhQ8VmHRfROiG9Y2MMKFtSR/B+c3jo3+wdT7OurRHIxr6lKq/IGE2UCyhDOZMsqDcXi1RYLTdPqraKTMTRpGWRB9gGpg1KrcYM2BOiHyyFxCaQJhVPjHeG2mk39nBk6u0vzkKydF4ApBTFDRHkKjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755806890; c=relaxed/simple; bh=3RfOoWzbZTj8EGhrr7OVQfmCtFM6TSZBuGB7jdppkcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=h/8PZT1IC/UY8OBuNuWbbDOBqD7s6W8XBn7UGxbhRgRu38gKaGnCRTvXvpJmZz+LlmKn/ZPMLe+B/cU1MNwm9PlxUyvfBNln4A0MPeaYzIU6DEEgYYdtd9tydoXumepwjsgBPoRiEw/n0OC1Ev17ZJAC17BEFQxOc5xiTbnhlwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=it6Taxzs; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="it6Taxzs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755806886; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jaRFM4K4Pg6WYlxhcM2k1BGbQ/DW6XfjnDsCttbmjXY=; b=it6TaxzsJDPMXPDc1E/08ppOd/mm4UqEyNn7OobTDnjuTG68zMYCaT1ItHMXombXlTaUW4 0k+SpBN4z03dxvQXdDHmpZF3c4eWynJlOgc2Tgq6l8eEe7OZd3c+ZY1CQxuf3gStboAA8p wMXehN8uJAhyhaeHztYxjF/1igORJTU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-LcTIlc0fOMCgw2EsoNCZKw-1; Thu, 21 Aug 2025 16:08:04 -0400 X-MC-Unique: LcTIlc0fOMCgw2EsoNCZKw-1 X-Mimecast-MFC-AGG-ID: LcTIlc0fOMCgw2EsoNCZKw_1755806883 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3b9edf41d07so651950f8f.3 for ; Thu, 21 Aug 2025 13:08:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755806883; x=1756411683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jaRFM4K4Pg6WYlxhcM2k1BGbQ/DW6XfjnDsCttbmjXY=; b=K+D22dZANPMLgOiw+cDNlzzJBbtGwINiIuWjJ73XFaZY2FCGyonUHbZ/esfIMkAXrx axJrFhxqQ6JfcZtQJG9Qu0rjmXnw8frSUbQRVu2oMO9ue0g0cAXd8NWJ0BFg+eli9ZpW wjOV1UFT9g19E2FL/dJmzSsdhE/CfzFEj9buZIZw9HF1CsB6ST47gS5lcguSFwcd0kQh ZosQAIEIJ0E9CKEsfTVQz9pvm6wHBplk+UN9ha1nnxG7xqgFOGfTJx6e8SeBlJgHhOWR wYsTu2uQjEaKdFxgh7qPuqzbqHErttUcph8KRNthKyz63L3gFXXimOaX+EYtD40tm8vh h8yQ== X-Forwarded-Encrypted: i=1; AJvYcCV4QzGZoCNDDUmy611ZFbNP/DgNdobl4k2IobwMbbe1BrfBYlvohIDsB2PAfwo//rS0xk5s6w==@lists.linux.dev X-Gm-Message-State: AOJu0YzLd2KlTRWzc65vj5DJjZJH80OWcyWCv9TqZXyJlFm4Comhp1EE 7HfVcuautkE20SSxQKoaj8yzPYJExuBRK/eAqRC3Sag5Nn8aiafXT8rA1oHPXaCgTEnZp82SZDO ZReJBfb+cgf5Cac29KsXT62xN56TO/8NXIU2TpnAyhwlZ5kolf4A+zIEwnRG1u30xcGE= X-Gm-Gg: ASbGncteuok3sAzJpPMVXOczlzNQP3jUYztlAxoD4e+8spo5Y+mTSnrHP3KkBbJnGJb krl8wP70fpT4bgi4j1r4KYhshp8l9vHFCMovnN1E2Po92kxe3J7UrQyjdbI0ZGMmutdy5O8+vSd pRFWDZD5MrycyFrXlwYKUuHv8PiIAhUIcqt/cFcPWIA3eONW4jzEbzN/1cEp5hkgXW+t3fWLcmP 0qGgQEJ2WAJHgyqCKOnz/IGO4+e8EKLT+87iajzbtcQQ5H63+uhViEXoAUNTLao3tA8CLok4h4Q gRJQN636n5h6Or1lLkmSC4i9LEFXAdPLJz/m1ZKc7VICtLNJd0cswbh9UYs3OecnpJ8uc/SRgYR /CXGc4o6r919McttJsucdxw== X-Received: by 2002:a05:6000:2012:b0:3b7:dd87:d741 with SMTP id ffacd0b85a97d-3c5dcc095c3mr196209f8f.42.1755806882818; Thu, 21 Aug 2025 13:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiRO9AsztHDXjXXwtKcCswXKV/HQQvQjujQOlltIgK9F5s1Ca8ikdDYrX2bvCVEtKZoFK6NA== X-Received: by 2002:a05:6000:2012:b0:3b7:dd87:d741 with SMTP id ffacd0b85a97d-3c5dcc095c3mr196155f8f.42.1755806882316; Thu, 21 Aug 2025 13:08:02 -0700 (PDT) Received: from localhost (p200300d82f26ba0008036ec5991806fd.dip0.t-ipconnect.de. [2003:d8:2f26:ba00:803:6ec5:9918:6fd]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-45b50e0b299sm8957945e9.22.2025.08.21.13.08.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Aug 2025 13:08:01 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Thomas Bogendoerfer , Alexander Potapenko , Andrew Morton , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, iommu@lists.linux.dev, io-uring@vger.kernel.org, Jason Gunthorpe , Jens Axboe , Johannes Weiner , John Hubbard , kasan-dev@googlegroups.com, kvm@vger.kernel.org, "Liam R. Howlett" , Linus Torvalds , linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-ide@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, Lorenzo Stoakes , Marco Elver , Marek Szyprowski , Michal Hocko , Mike Rapoport , Muchun Song , netdev@vger.kernel.org, Oscar Salvador , Peter Xu , Robin Murphy , Suren Baghdasaryan , Tejun Heo , virtualization@lists.linux.dev, Vlastimil Babka , wireguard@lists.zx2c4.com, x86@kernel.org, Zi Yan Subject: [PATCH RFC 20/35] mips: mm: convert __flush_dcache_pages() to __flush_dcache_folio_pages() Date: Thu, 21 Aug 2025 22:06:46 +0200 Message-ID: <20250821200701.1329277-21-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250821200701.1329277-1-david@redhat.com> References: <20250821200701.1329277-1-david@redhat.com> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PjdOlcoRuXpSDAVOQs1RTmj-kHuzJ_GCQKXpz-kWM0o_1755806883 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Let's make it clearer that we are operating within a single folio by providing both the folio and the page. This implies that for flush_dcache_folio() we'll now avoid one more page->folio lookup, and that we can safely drop the "nth_page" usage. Cc: Thomas Bogendoerfer Signed-off-by: David Hildenbrand --- arch/mips/include/asm/cacheflush.h | 11 +++++++---- arch/mips/mm/cache.c | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h index 1f14132b3fc98..8a2de28936e07 100644 --- a/arch/mips/include/asm/cacheflush.h +++ b/arch/mips/include/asm/cacheflush.h @@ -50,13 +50,14 @@ extern void (*flush_cache_mm)(struct mm_struct *mm); extern void (*flush_cache_range)(struct vm_area_struct *vma, unsigned long start, unsigned long end); extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn); -extern void __flush_dcache_pages(struct page *page, unsigned int nr); +extern void __flush_dcache_folio_pages(struct folio *folio, struct page *page, unsigned int nr); #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 static inline void flush_dcache_folio(struct folio *folio) { if (cpu_has_dc_aliases) - __flush_dcache_pages(&folio->page, folio_nr_pages(folio)); + __flush_dcache_folio_pages(folio, folio_page(folio, 0), + folio_nr_pages(folio)); else if (!cpu_has_ic_fills_f_dc) folio_set_dcache_dirty(folio); } @@ -64,10 +65,12 @@ static inline void flush_dcache_folio(struct folio *folio) static inline void flush_dcache_page(struct page *page) { + struct folio *folio = page_folio(page); + if (cpu_has_dc_aliases) - __flush_dcache_pages(page, 1); + __flush_dcache_folio_pages(folio, page, folio_nr_pages(folio)); else if (!cpu_has_ic_fills_f_dc) - folio_set_dcache_dirty(page_folio(page)); + folio_set_dcache_dirty(folio); } #define flush_dcache_mmap_lock(mapping) do { } while (0) diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index bf9a37c60e9f0..e3b4224c9a406 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c @@ -99,9 +99,9 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes, return 0; } -void __flush_dcache_pages(struct page *page, unsigned int nr) +void __flush_dcache_folio_pages(struct folio *folio, struct page *page, + unsigned int nr) { - struct folio *folio = page_folio(page); struct address_space *mapping = folio_flush_mapping(folio); unsigned long addr; unsigned int i; @@ -117,12 +117,12 @@ void __flush_dcache_pages(struct page *page, unsigned int nr) * get faulted into the tlb (and thus flushed) anyways. */ for (i = 0; i < nr; i++) { - addr = (unsigned long)kmap_local_page(nth_page(page, i)); + addr = (unsigned long)kmap_local_page(page + i); flush_data_cache_page(addr); kunmap_local((void *)addr); } } -EXPORT_SYMBOL(__flush_dcache_pages); +EXPORT_SYMBOL(__flush_dcache_folio_pages); void __flush_anon_page(struct page *page, unsigned long vmaddr) { -- 2.50.1