From: Chintan Pandya <chintan.pandya@oneplus.com>
To: Linux Upstream <linux.upstream@oneplus.com>,
"hughd@google.com" <hughd@google.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"jack@suse.cz" <jack@suse.cz>,
"mawilcox@microsoft.com" <mawilcox@microsoft.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Chintan Pandya <chintan.pandya@oneplus.com>
Subject: [RFC 2/2] page-flags: Catch the double setter of page flags
Date: Mon, 11 Feb 2019 12:53:55 +0000 [thread overview]
Message-ID: <20190211125337.16099-3-chintan.pandya@oneplus.com> (raw)
In-Reply-To: <20190211125337.16099-1-chintan.pandya@oneplus.com>
Some of the page flags, like PG_locked is not supposed to
be set twice. Currently, there is no protection around this
and many callers directly tries to set this bit. Others
follow trylock_page() which is much safer version of the
same. But, for performance issues, we may not want to
implement wait-until-set. So, at least, find out who is
doing double setting and fix them.
Change-Id: I1295fcb8527ce4b54d5d11c11287fc7516006cf0
Signed-off-by: Chintan Pandya <chintan.pandya@oneplus.com>
---
include/linux/page-flags.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index a56a9bd4bc6b..e307775c2b4a 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -208,7 +208,7 @@ static __always_inline int Page##uname(struct page *page) \
#define SETPAGEFLAG(uname, lname, policy) \
static __always_inline void SetPage##uname(struct page *page) \
- { set_bit(PG_##lname, &policy(page, 1)->flags); }
+ { WARN_ON(test_and_set_bit(PG_##lname, &policy(page, 1)->flags)); }
#define CLEARPAGEFLAG(uname, lname, policy) \
static __always_inline void ClearPage##uname(struct page *page) \
--
2.17.1
next prev parent reply other threads:[~2019-02-11 12:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 12:53 [RFC 0/2] Potential race condition with page lock Chintan Pandya
2019-02-11 12:53 ` [RFC 1/2] page-flags: Make page lock operation atomic Chintan Pandya
2019-02-11 13:46 ` Peter Zijlstra
2019-02-11 13:59 ` Linux Upstream
2019-02-11 17:48 ` Jan Kara
2019-02-11 17:56 ` Matthew Wilcox
2019-02-12 7:45 ` Jan Kara
2019-02-12 12:29 ` Peter Zijlstra
2019-02-11 12:53 ` Chintan Pandya [this message]
2019-02-11 13:47 ` [RFC 2/2] page-flags: Catch the double setter of page flags Peter Zijlstra
2019-02-11 14:01 ` Linux Upstream
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=20190211125337.16099-3-chintan.pandya@oneplus.com \
--to=chintan.pandya@oneplus.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux.upstream@oneplus.com \
--cc=mawilcox@microsoft.com \
--cc=peterz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.