From: Ira Weiny <ira.weiny@intel.com>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Kees Cook <keescook@chromium.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
<linux-kernel@vger.kernel.org>, David Sterba <dsterba@suse.cz>
Subject: Re: [PATCH] highmem: Make __kunmap_{local,atomic}() take "const void *"
Date: Tue, 14 Jun 2022 07:39:57 -0700 [thread overview]
Message-ID: <YqidvW4Yw6p5Bcmv@iweiny-desk3> (raw)
In-Reply-To: <20220614142531.16478-1-fmdefrancesco@gmail.com>
On Tue, Jun 14, 2022 at 04:25:31PM +0200, Fabio M. De Francesco wrote:
> Sometimes __kunmap_{local,atomic}() should take pointers to const void.
> Currently their prototypes take pointers to void, therefore compilations
> break in cases like the above-mentioned.
I think the compilation problem is just a symptom of the real issue.
kunmap_local() has no reason to change the vaddr parameter and therefore it is
correct to declare it a const.
This allows callers to also maintain vaddr as a const value to be passed back
to kumap_local() if they wish.
Ira
>
> This is the output of GCC-12 when it encounters one those cases:
>
> ./linux/fs/btrfs/zstd.c:547:33: warning: passing
> argument 1 of '__kunmap_local' discards 'const' qualifier from pointer
> target type [-Wdiscarded-qualifiers]
> 547 | kunmap_local(workspace->in_buf.src);
> | ~~~~~~~~~~~~~~~~~^~~~
> ./linux/include/linux/highmem-internal.h:284:17:
> note: in definition of macro 'kunmap_local'
> 284 | __kunmap_local(__addr); \
> | ^~~~~~
> ./linux/include/linux/highmem-internal.h:92:41:
> note: expected 'void *' but argument is of type 'const void *'
> 92 | static inline void __kunmap_local(void *vaddr)
> | ~~~~~~^~~~~
>
> Make __kunmap_{local,atomic}() take pointers to const void.
>
> Suggested-by: David Sterba <dsterba@suse.cz>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
> include/linux/highmem-internal.h | 10 +++++-----
> mm/highmem.c | 2 +-
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
> index cddb42ff0473..034b1106d022 100644
> --- a/include/linux/highmem-internal.h
> +++ b/include/linux/highmem-internal.h
> @@ -8,7 +8,7 @@
> #ifdef CONFIG_KMAP_LOCAL
> void *__kmap_local_pfn_prot(unsigned long pfn, pgprot_t prot);
> void *__kmap_local_page_prot(struct page *page, pgprot_t prot);
> -void kunmap_local_indexed(void *vaddr);
> +void kunmap_local_indexed(const void *vaddr);
> void kmap_local_fork(struct task_struct *tsk);
> void __kmap_local_sched_out(void);
> void __kmap_local_sched_in(void);
> @@ -89,7 +89,7 @@ static inline void *kmap_local_pfn(unsigned long pfn)
> return __kmap_local_pfn_prot(pfn, kmap_prot);
> }
>
> -static inline void __kunmap_local(void *vaddr)
> +static inline void __kunmap_local(const void *vaddr)
> {
> kunmap_local_indexed(vaddr);
> }
> @@ -121,7 +121,7 @@ static inline void *kmap_atomic_pfn(unsigned long pfn)
> return __kmap_local_pfn_prot(pfn, kmap_prot);
> }
>
> -static inline void __kunmap_atomic(void *addr)
> +static inline void __kunmap_atomic(const void *addr)
> {
> kunmap_local_indexed(addr);
> pagefault_enable();
> @@ -197,7 +197,7 @@ static inline void *kmap_local_pfn(unsigned long pfn)
> return kmap_local_page(pfn_to_page(pfn));
> }
>
> -static inline void __kunmap_local(void *addr)
> +static inline void __kunmap_local(const void *addr)
> {
> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> kunmap_flush_on_unmap(addr);
> @@ -224,7 +224,7 @@ static inline void *kmap_atomic_pfn(unsigned long pfn)
> return kmap_atomic(pfn_to_page(pfn));
> }
>
> -static inline void __kunmap_atomic(void *addr)
> +static inline void __kunmap_atomic(const void *addr)
> {
> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> kunmap_flush_on_unmap(addr);
> diff --git a/mm/highmem.c b/mm/highmem.c
> index 1a692997fac4..e32083e4ce0d 100644
> --- a/mm/highmem.c
> +++ b/mm/highmem.c
> @@ -561,7 +561,7 @@ void *__kmap_local_page_prot(struct page *page, pgprot_t prot)
> }
> EXPORT_SYMBOL(__kmap_local_page_prot);
>
> -void kunmap_local_indexed(void *vaddr)
> +void kunmap_local_indexed(const void *vaddr)
> {
> unsigned long addr = (unsigned long) vaddr & PAGE_MASK;
> pte_t *kmap_pte;
> --
> 2.36.1
>
next prev parent reply other threads:[~2022-06-14 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 14:25 Fabio M. De Francesco
2022-06-14 14:39 ` Ira Weiny [this message]
2022-06-15 14:08 ` kernel test robot
2022-06-15 17:32 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YqidvW4Yw6p5Bcmv@iweiny-desk3 \
--to=ira.weiny@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=dsterba@suse.cz \
--cc=fmdefrancesco@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®