Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751838AbbBJHLl (ORCPT ); Tue, 10 Feb 2015 02:11:41 -0500 Received: from cnbjrel02.sonyericsson.com ([219.141.167.166]:13054 "EHLO cnbjrel02.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751445AbbBJHLk convert rfc822-to-8bit (ORCPT ); Tue, 10 Feb 2015 02:11:40 -0500 From: "Wang, Yalin" To: "'viro@zeniv.linux.org.uk'" , "'linux-fsdevel@vger.kernel.org'" , "'linux-kernel@vger.kernel.org'" , "Gao, Neil" Date: Tue, 10 Feb 2015 15:11:37 +0800 Subject: [RFC V2] test_bit before clear files_struct bits Thread-Topic: [RFC V2] test_bit before clear files_struct bits Thread-Index: AdBFACgEc97JUPvYTWSBybSTiDc3HgAAIyYw Message-ID: <35FD53F367049845BC99AC72306C23D1044A02027E19@CNBJMBX05.corpusers.net> References: <35FD53F367049845BC99AC72306C23D1044A02027E18@CNBJMBX05.corpusers.net> In-Reply-To: <35FD53F367049845BC99AC72306C23D1044A02027E18@CNBJMBX05.corpusers.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1371 Lines: 40 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 clear_bit, and we can win in most time. Signed-off-by: Yalin Wang --- fs/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/file.c b/fs/file.c index ee738ea..b0e059c 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->open_fds)) { /* * The fd may be claimed in the fd bitmap but not yet * instantiated in the files array if a sibling thread -- 2.2.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/