linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com,
	pasha.tatashin@soleen.com
Subject: Re: [PATCH 1/5] mm: Constify a lot of struct page arguments
Date: Thu, 9 Apr 2020 07:15:50 -0700	[thread overview]
Message-ID: <20200409141550.GU21484@bombadil.infradead.org> (raw)
In-Reply-To: <20200409140914.u3mff4xrk5u4tvht@box>

On Thu, Apr 09, 2020 at 05:09:14PM +0300, Kirill A. Shutemov wrote:
> On Wed, Apr 08, 2020 at 08:01:44AM -0700, Matthew Wilcox wrote:
> > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> > index 4aba6c0c2ba8..a8c3fa076f43 100644
> > --- a/include/linux/mm_types.h
> > +++ b/include/linux/mm_types.h
> > @@ -221,15 +221,8 @@ struct page {
> >  #endif
> >  } _struct_page_alignment;
> >  
> > -static inline atomic_t *compound_mapcount_ptr(struct page *page)
> > -{
> > -	return &page[1].compound_mapcount;
> > -}
> > -
> > -static inline atomic_t *compound_pincount_ptr(struct page *page)
> > -{
> > -	return &page[2].hpage_pinned_refcount;
> > -}
> > +#define compound_mapcount_ptr(page)	(&(page)[1].compound_mapcount)
> > +#define compound_pincount_ptr(page)	(&(page)[2].hpage_pinned_refcount)
> 
> Looks like this conversion is not covered by the reason given in the
> commit message. Hm?

They were supposed to be covered by "That means some inline functions
have to become macros so they can return a struct page which is the same
const-ness as their argument."

They're not quite covered since they need to return an atomic_t that
is the same constness as their argument.

> > +#define compound_head(page) ({						\
> > +	__typeof__(page) _page = page;					\
> > +	unsigned long head = READ_ONCE(_page->compound_head);		\
> > +	if (unlikely(head & 1))						\
> > +		_page = (void *)(head - 1);				\
> > +	_page;								\
> > +})
> 
> Ugh..
> 
> Other option would be to make compound_head() take 'const struct page *'
> and return 'void *'. It arguably would provide better type safety, no?

We have a few places that do things like

mm/filemap.c:           if (unlikely(compound_head(page)->mapping != mapping)) {



  reply	other threads:[~2020-04-09 14:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 15:01 [PATCH 0/5] Improve page poisoning implementation Matthew Wilcox
2020-04-08 15:01 ` [PATCH 1/5] mm: Constify a lot of struct page arguments Matthew Wilcox
2020-04-08 15:14   ` Pavel Tatashin
2020-04-09 14:09   ` Kirill A. Shutemov
2020-04-09 14:15     ` Matthew Wilcox [this message]
2020-04-09 14:28       ` Kirill A. Shutemov
2020-04-09 14:32         ` Matthew Wilcox
2020-04-09 14:47           ` Kirill A. Shutemov
2020-04-09 15:00             ` Kirill A. Shutemov
2020-04-09 17:12             ` Jason Gunthorpe
2020-04-09 20:47               ` John Hubbard
2020-04-08 15:01 ` [PATCH 2/5] mm: Rename PF_POISONED_PAGE to page_poison_check Matthew Wilcox
2020-04-08 15:21   ` Pavel Tatashin
2020-04-09 14:14   ` Kirill A. Shutemov
2020-04-08 15:01 ` [PATCH 3/5] mm: Remove casting away of constness Matthew Wilcox
2020-04-08 15:23   ` Pavel Tatashin
2020-04-09 14:19   ` Kirill A. Shutemov
2020-04-08 15:01 ` [PATCH 4/5] mm: Check for page poison in both page_to_nid implementations Matthew Wilcox
2020-04-08 15:24   ` Pavel Tatashin
2020-04-09 14:21   ` Kirill A. Shutemov
2020-04-08 15:01 ` [PATCH 5/5] mm: Check page poison before finding a head page Matthew Wilcox
2020-04-08 15:32   ` Pavel Tatashin
2020-04-09 14:25   ` Kirill A. Shutemov
2020-04-08 15:11 ` [PATCH 0/5] Improve page poisoning implementation Pavel Tatashin
2020-04-09 20:55   ` John Hubbard

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=20200409141550.GU21484@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    /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