mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wang, Yalin" <Yalin.Wang@sonymobile.com>
To: "'viro@zeniv.linux.org.uk'" <viro@zeniv.linux.org.uk>,
	"'linux-fsdevel@vger.kernel.org'" <linux-fsdevel@vger.kernel.org>,
	"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
	"Gao, Neil" <Neil.Gao@sonymobile.com>
Subject: [RFC] test_bit before clear files_struct bits
Date: Tue, 10 Feb 2015 15:06:57 +0800	[thread overview]
Message-ID: <35FD53F367049845BC99AC72306C23D1044A02027E18@CNBJMBX05.corpusers.net> (raw)

add test_bit() before clear close_on_exec and open_fds,
by trace __clear_bit(), these 2 place are false in most times,
we test it so that we don't need dirty cacheline, and we can win
in most time.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
 fs/file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index ee738ea..2fd296b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -209,7 +209,8 @@ static inline void __set_close_on_exec(int fd, struct fdtable *fdt)
 
 static inline void __clear_close_on_exec(int fd, struct fdtable *fdt)
 {
-	__clear_bit(fd, fdt->close_on_exec);
+	if (test_bit(fd, fdt->close_on_exec))
+		__clear_bit(fd, fdt->close_on_exec);
 }
 
 static inline void __set_open_fd(int fd, struct fdtable *fdt)
@@ -309,7 +310,7 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)
 		struct file *f = *old_fds++;
 		if (f) {
 			get_file(f);
-		} else {
+		} else if (test_bit(open_files - i, new_fdt)) {
 			/*
 			 * The fd may be claimed in the fd bitmap but not yet
 			 * instantiated in the files array if a sibling thread
-- 
2.2.2

             reply	other threads:[~2015-02-10  7:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10  7:06 Wang, Yalin [this message]
2015-02-10  7:11 ` [RFC V2] " Wang, Yalin
2015-02-10 20:22   ` Andrew Morton
2015-02-10 20:49     ` Linus Torvalds
2015-02-10 22:46       ` Kirill A. Shutemov
2015-02-10 23:29         ` Linus Torvalds
2015-02-15  8:27   ` [RFC V3] test bit " Wang, Yalin
2015-02-18 21:27     ` Andrew Morton

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=35FD53F367049845BC99AC72306C23D1044A02027E18@CNBJMBX05.corpusers.net \
    --to=yalin.wang@sonymobile.com \
    --cc=Neil.Gao@sonymobile.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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®