From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA6FEC636CC for ; Thu, 16 Feb 2023 14:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AbQcvzH1+lULGO7Z4tBTWGRiUCgdc+XoXQpzMpAosR0=; b=1wM++6ULWU00Pq rvE3+mRU4E4DkfOjPZc/3R/RwNpnm2EJr/VMLCEPZ4+ggT4OfFkPowOgC5Ykzha74s7f6/+B80+SN urL6dN0Drw4d7LKvD1BjOy+Y83ucBKO8C1zCPDUpUGV5FjPda0ZuQJg/MKX1NHhSnQsvyZxGZjSxB l5roEi2MrxCHCWkfpwuwJMMknNTPhZ4Wd7qTdHPf8TmY0u3JiHv4CPErviS7Q6X2UKqivx8+Rw+nA nfRJdtMMjdiZko+LIIiYjlXKFxapr/hnk01B8tgfKKRavwLxtFd6/q4eCXqNh9vZQX044FSQwU0D9 d3iNWBcgLcpRkHhtzF3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSfEx-00AcTl-M4; Thu, 16 Feb 2023 14:28:04 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSfEn-00AcQh-NI for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2023 14:27:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DAE160EC0; Thu, 16 Feb 2023 14:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D8B5C433D2; Thu, 16 Feb 2023 14:27:50 +0000 (UTC) Date: Thu, 16 Feb 2023 14:27:47 +0000 From: Catalin Marinas To: Peter Collingbourne Cc: andreyknvl@gmail.com, linux-mm@kvack.org, kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com, linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com, will@kernel.org, eugenis@google.com Subject: Re: [PATCH] kasan: call clear_page with a match-all tag instead of changing page tag Message-ID: References: <20230216064726.2724268-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230216064726.2724268-1-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230216_062753_850852_8C02E6AC X-CRM114-Status: GOOD ( 19.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Feb 15, 2023 at 10:47:26PM -0800, Peter Collingbourne wrote: > Instead of changing the page's tag solely in order to obtain a pointer > with a match-all tag and then changing it back again, just convert the > pointer that we get from kmap_atomic() into one with a match-all tag > before passing it to clear_page(). > > On a certain microarchitecture, this has been observed to cause a > measurable improvement in microbenchmark performance, presumably as a > result of being able to avoid the atomic operations on the page tag. Yeah, this would likely break the write streaming mode on some ARM CPUs. > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/I0249822cc29097ca7a04ad48e8eb14871f80e711 > --- > include/linux/highmem.h | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/include/linux/highmem.h b/include/linux/highmem.h > index 44242268f53b..bbfa546dd602 100644 > --- a/include/linux/highmem.h > +++ b/include/linux/highmem.h > @@ -245,12 +245,10 @@ static inline void clear_highpage(struct page *page) > > static inline void clear_highpage_kasan_tagged(struct page *page) > { > - u8 tag; > + void *kaddr = kmap_atomic(page); > > - tag = page_kasan_tag(page); > - page_kasan_tag_reset(page); > - clear_highpage(page); > - page_kasan_tag_set(page, tag); > + clear_page(kasan_reset_tag(kaddr)); > + kunmap_atomic(kaddr); > } Please don't add kmap_atomic() back. See commit d2c20e51e396 ("mm/highmem: remove deprecated kmap_atomic"). I'd duplicate the clear_highpage() logic in here and call clear_page() directly on the address with the kasan tag reset. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel