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 X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CE74C4363A for ; Wed, 28 Oct 2020 11:07:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE498246A0 for ; Wed, 28 Oct 2020 11:07:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xdwvVAMH"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="h3qRf1hh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE498246A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xMTikwmPHkicm2rLxbU5v7Sec9M6tqahLc11jAqH0jM=; b=xdwvVAMHIr970bFQ10kPlkQC7 1OalpiSDV3JiIVhJRUU5FZnfL4L//ndoEzmTD8OvgyPp0dIaWg+e33K8Fdybaoc+f5OPD5BA/zQ6X Ll8OXSzPE3X/EMFpHIJ3fTcgYKHF1KMp+WE6c0t0R2tgHSetJy38kFop0gA8aJgJRU3/mSlYbl2+o CZBMEJ/EExciyrCySt3aH6L+kVZAvNZ+ukjhsbRzzxecUthnN0k5xZF6xaFS7BuJS4fBQTENHIWLE Z1sM+MC6FjTAkNJSPpgi4NN/RidvLIYwIY7SJZrkq8AcoP7oiK9B3zluC1YfpWsJOFiTkyAbEznSL lGp25Mzag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXjGs-0003z9-Qi; Wed, 28 Oct 2020 11:05:38 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXjGp-0003yK-Og for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2020 11:05:37 +0000 Received: by mail-qk1-x742.google.com with SMTP id z6so4065754qkz.4 for ; Wed, 28 Oct 2020 04:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BnTFjO5iPodWJwaiH+f8UvOorIZZfBBlIOwtDZT/AaY=; b=h3qRf1hhxPBFncyZU6ggg2vVRf3ny01avB3rYfcswnrnL7hpcvdQ/ffCr5ZbjB6NqW tlk7dvRBAX/tOJ++AAhJYiuW2zodOUkl8Gk58vDUuiblXQ9ZLGcDn8jLflHztUhbZWKE y4PN9oFn0AXRD4aSeNw4YsPkeFXja10LLv9FYGvelX2DjbrT5nR+S13oUOoPFrnLrUKo qOeHjJwAzGjgqJr4ADWW4oQZ0Bpi/dklAUdtQVBYAoH/se+qGLX9AA160DVpvCl9Qjit jv2iw7KvirDZ+Uk+DwP1LDgwoP0dH43sIQKbJHVLaZ9Lq7n6dWVC2R8vhv1jO8OKw0ev v/Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BnTFjO5iPodWJwaiH+f8UvOorIZZfBBlIOwtDZT/AaY=; b=a38kNaPvxVB7KfnTT/1kck3UfoEXvaFdhc6RF1MoGPQYpPGrK1IJriyJY8fuq+CNJb 9NYIrAI0w0LFsyq3zzEikv/DrWH14U8o/3qTF6OiZsDeUgW6hj4UwN7Ar4VtM4EUesfN JPtoHSbw0ohHtOGaX1t7tunSWbZU+vhQ+RByX6xka8eFSPSRgCFu3b08imkso/LjGpGi FS9nmR6aztsh4yWOSMbHvXvhDOUw41CFsLpTHDS8ZQ4ZmCMT1bMYZzdNBBnQiDTCx53w JnEAu0bdIxIPPl/7U71hXsrVeroO1iyGShJAuH9nlmf83hjRF5BbVfKYe7oozf0l4B8w 7lTw== X-Gm-Message-State: AOAM533tNB2VaN2KbFU2NDZptpwCTAEdiO7sYIEIFyJSRjFZTQTbpkyw U1SEzH0vcTmKOuxYvyYEd3hW0R2KbdMZTj8hV+y+9A== X-Google-Smtp-Source: ABdhPJzaSm5cm7TtWwkPsVr7gNmNlCL4EX8BlsO0vzHgljAGxOVHvBFFcnrWGxTyWKQ8aPnxQqB2zP5KvizdBxj5bJE= X-Received: by 2002:a37:a00c:: with SMTP id j12mr834383qke.231.1603883132900; Wed, 28 Oct 2020 04:05:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dmitry Vyukov Date: Wed, 28 Oct 2020 12:05:21 +0100 Message-ID: Subject: Re: [PATCH RFC v2 09/21] kasan: inline kasan_reset_tag for tag-based modes To: Andrey Konovalov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201028_070536_180640_B6186B66 X-CRM114-Status: GOOD ( 22.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marco Elver , Elena Petrova , Linux-MM , Catalin Marinas , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev , LKML , Kostya Serebryany , Alexander Potapenko , Linux ARM , Serban Constantinescu , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Peter Collingbourne , Evgenii Stepanov 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 Thu, Oct 22, 2020 at 3:19 PM Andrey Konovalov wrote: > > Using kasan_reset_tag() currently results in a function call. As it's > called quite often from the allocator code this leads to a noticeable > slowdown. Move it to include/linux/kasan.h and turn it into a static > inline function. > > Signed-off-by: Andrey Konovalov > Link: https://linux-review.googlesource.com/id/I4d2061acfe91d480a75df00b07c22d8494ef14b5 > --- > include/linux/kasan.h | 5 ++++- > mm/kasan/hw_tags.c | 5 ----- > mm/kasan/kasan.h | 6 ++---- > mm/kasan/sw_tags.c | 5 ----- > 4 files changed, 6 insertions(+), 15 deletions(-) > > diff --git a/include/linux/kasan.h b/include/linux/kasan.h > index 93d9834b7122..6377d7d3a951 100644 > --- a/include/linux/kasan.h > +++ b/include/linux/kasan.h > @@ -187,7 +187,10 @@ static inline void kasan_record_aux_stack(void *ptr) {} > > void __init kasan_init_tags(void); > > -void *kasan_reset_tag(const void *addr); > +static inline void *kasan_reset_tag(const void *addr) > +{ > + return (void *)arch_kasan_reset_tag(addr); It seems that all implementations already return (void *), so the cast is not needed. > +} > > bool kasan_report(unsigned long addr, size_t size, > bool is_write, unsigned long ip); > diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c > index b372421258c8..c3a0e83b5e7a 100644 > --- a/mm/kasan/hw_tags.c > +++ b/mm/kasan/hw_tags.c > @@ -24,11 +24,6 @@ void __init kasan_init_tags(void) > pr_info("KernelAddressSanitizer initialized\n"); > } > > -void *kasan_reset_tag(const void *addr) > -{ > - return reset_tag(addr); > -} > - > void kasan_poison_memory(const void *address, size_t size, u8 value) > { > set_mem_tag_range(reset_tag(address), > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h > index 456b264e5124..0ccbb3c4c519 100644 > --- a/mm/kasan/kasan.h > +++ b/mm/kasan/kasan.h > @@ -246,15 +246,13 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) > return addr; > } > #endif > -#ifndef arch_kasan_reset_tag > -#define arch_kasan_reset_tag(addr) ((void *)(addr)) > -#endif > #ifndef arch_kasan_get_tag > #define arch_kasan_get_tag(addr) 0 > #endif > > +/* kasan_reset_tag() defined in include/linux/kasan.h. */ > +#define reset_tag(addr) ((void *)kasan_reset_tag(addr)) The cast is not needed. I would also now remove reset_tag entirely by replacing it with kasan_reset_tag. Having 2 names for the same thing does not add clarity. > #define set_tag(addr, tag) ((void *)arch_kasan_set_tag((addr), (tag))) > -#define reset_tag(addr) ((void *)arch_kasan_reset_tag(addr)) > #define get_tag(addr) arch_kasan_get_tag(addr) > > #ifndef arch_init_tags > diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c > index 099af6dc8f7e..4db41f274702 100644 > --- a/mm/kasan/sw_tags.c > +++ b/mm/kasan/sw_tags.c > @@ -67,11 +67,6 @@ u8 random_tag(void) > return (u8)(state % (KASAN_TAG_MAX + 1)); > } > > -void *kasan_reset_tag(const void *addr) > -{ > - return reset_tag(addr); > -} > - > bool check_memory_region(unsigned long addr, size_t size, bool write, > unsigned long ret_ip) > { > -- > 2.29.0.rc1.297.gfa9743e501-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel