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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham 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 0C3DEC433DB for ; Mon, 22 Feb 2021 07:41:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 79E7364D73 for ; Mon, 22 Feb 2021 07:41:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79E7364D73 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EDF766B006E; Mon, 22 Feb 2021 02:41:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8F826B0070; Mon, 22 Feb 2021 02:41:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7ECA6B0071; Mon, 22 Feb 2021 02:41:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id C250A6B006E for ; Mon, 22 Feb 2021 02:41:04 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8B4898248047 for ; Mon, 22 Feb 2021 07:41:04 +0000 (UTC) X-FDA: 77845107648.18.1857B4B Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf08.hostedemail.com (Postfix) with ESMTP id 5608980192D8 for ; Mon, 22 Feb 2021 07:40:54 +0000 (UTC) Received: by mail-qt1-f170.google.com with SMTP id h16so8597478qth.11 for ; Sun, 21 Feb 2021 23:41:03 -0800 (PST) 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=DA1rxnC139fkp05L9pB0MTnjTfTAu6RLwtL0vBni21U=; b=nGMJCi599OHaEdNZ7F43xUzzmAXDfVdQdevDDxZSt5NjkfL4LbvGXHAeJeiAUjEMi8 b0R4hhKY1/Cphtdr0MlSZiSRPN/DGgc2HlwkLxpRZvdjvyWeOGzu9dAd3ZSvDt6uRAKO RZ8sM752Ey3Ypv4veCTldoJuGk9Fpgk5NIRlUoDZw3fxcvKbe7UEGvPJiZJheb1Qrkfw 6XXMjuAj0xLP31uoZcbem8bWq6LziPqzDTutOl1wx1dApsrSGKZgkHzCxuvnDV9J+8pg duw6CKmByxa8vExGrFIiYIxwSSLlwjO5G9TX0eswcM9w+4ir6gkTXgDwlXoK7UL4C6cb MtdQ== 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=DA1rxnC139fkp05L9pB0MTnjTfTAu6RLwtL0vBni21U=; b=bBBrWwZb5oSwAuLQOUFLiM4iHQowyu0+8mmUkXzJxW1ePVmV1Kuvpf/9VADSSmcBnv s0+KiHh/sdOn5wx0BSqcDyBxoMJkEap5txcz8+emDgIu/e/fgIrD+vQK5gOiP7oh8FDQ hYtwLvdIqO+OkVIo2Srri4EcrPj0e41z4X0cIDj39iogFZTJBzRHNCqhhQm1mwmarJrs u3FG/jc06nY18cd5kuI8UG67vJMBxFlGhaIpFuDQQZdId/ZxTkrqdkqe+MAI3rll4Mve Yxd+FtF5nQ3XEkkhrWF/sqebXnyrmEldrQiB7NTI2xydjeK93yXob64UnA2MBeGLISU6 CUFA== X-Gm-Message-State: AOAM533daypFzPvYSPolY6PDdqfqoZkwW2z2Wm/wa0joIqaDxQgUdYAb Lyze5sHPayVRxqL5urGRB4HdSTiEx6uEvpUqDRKbRg== X-Google-Smtp-Source: ABdhPJx7BnWAwov5nD9bfnPzRN1tPJXq+RZFhkRhLPJ2suK22dWd/su1zLLZP03qTw0pJAr6aImMXD5KfIcFf+NtoTU= X-Received: by 2002:ac8:7514:: with SMTP id u20mr19064148qtq.66.1613979663168; Sun, 21 Feb 2021 23:41:03 -0800 (PST) MIME-Version: 1.0 References: <1613971347-24213-1-git-send-email-daizhiyuan@phytium.com.cn> In-Reply-To: <1613971347-24213-1-git-send-email-daizhiyuan@phytium.com.cn> From: Dmitry Vyukov Date: Mon, 22 Feb 2021 08:40:51 +0100 Message-ID: Subject: Re: [PATCH] mm/kasan: remove volatile keyword To: Zhiyuan Dai Cc: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Andrew Morton , kasan-dev , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: bfpdjqsm1efygfyci57347xzsqpxhu1n X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5608980192D8 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mail-qt1-f170.google.com; client-ip=209.85.160.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613979654-785500 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000066, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Feb 22, 2021 at 6:22 AM Zhiyuan Dai wrote: > > Like volatile, the kernel primitives which make concurrent > access to data safe (spinlocks, mutexes, memory barriers, > etc.) are designed to prevent unwanted optimization. > > If they are being used properly, there will be no need to > use volatile as well. If volatile is still necessary, > there is almost certainly a bug in the code somewhere. > In properly-written kernel code, volatile can only serve > to slow things down. > > see: Documentation/process/volatile-considered-harmful.rst Nack. This function does not require volatile variables. It uses volatile in the same way as C/C++ atomic functions -- it only supports operating on volatile variables. The same meaning as for const here. Such functions need to use all possible type modifiers to support all possible uses. Anyway, the function is declared in kasan.h. So you would need to change the signate there in the first place. But the kernel will either not compile, or it won't compile in future when somebody adds __kasan_check_read/write for a volatile variable. Such a change first requires removing all volatile uses from the entire kernel and banning volatile. > Signed-off-by: Zhiyuan Dai > --- > mm/kasan/shadow.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c > index 7c2c08c..d5ff9ca 100644 > --- a/mm/kasan/shadow.c > +++ b/mm/kasan/shadow.c > @@ -25,13 +25,13 @@ > > #include "kasan.h" > > -bool __kasan_check_read(const volatile void *p, unsigned int size) > +bool __kasan_check_read(const void *p, unsigned int size) > { > return check_memory_region((unsigned long)p, size, false, _RET_IP_); > } > EXPORT_SYMBOL(__kasan_check_read); > > -bool __kasan_check_write(const volatile void *p, unsigned int size) > +bool __kasan_check_write(const void *p, unsigned int size) > { > return check_memory_region((unsigned long)p, size, true, _RET_IP_); > } > -- > 1.8.3.1 >