Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1539932imu; Sun, 18 Nov 2018 04:03:57 -0800 (PST) X-Google-Smtp-Source: AJdET5fQxR+FcqbO80gk4hFUs9myjl2KW1NDs5T8hpf3ZAZeHz0xyn/tuhC+w/HMWjgiSZwqeVKN X-Received: by 2002:a62:8096:: with SMTP id j144mr18990368pfd.140.1542542637044; Sun, 18 Nov 2018 04:03:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542542637; cv=none; d=google.com; s=arc-20160816; b=cPXDgtF5GmnjPrtRN1dDHruGBiF0wshnd3zwM7nTycLITqm0Tc9p9Gxd2YJB7uhfPx Dm7FWQMWW9yHZrL0jzKB349otM7eB4CZPPFGivY8ro34Uguh4m1FilkGwoQlJg+6vfN9 5JmVNjQbMEAVwWva787PRWNqVSRNaOlj4ugkOVeblGR+BZmnUL6dye6fCaTFRtf7fOix 9LjwnyVl4+hsaAi5Q9yJUGBZvC0fApShAomJbtVkgxkNj9y5Dygjpxp7PfGw/B/ISbKk UsH25awEWQhPyhYFwBbL6njv/K2TaeFyVlL+mGQQh9taZy5fwI7VnqCR9BTwlfaVOZa8 NYkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=b1ZYnLYN4ir4UacvVkD3Q/B6raJ1AexezCEPoh1Pabs=; b=BKFuEA6W/6V+q1trIwndA5WS86JkqBJJPYYAUu8fdlrbA9cR6SY04sM+UBeyIfW7l6 1BTOqqbzvtUSBdyW0+LtFUni+KZIjn8mMvsxqbN2z4t9yznwg7ojyEooJlzIzBagZaQG WFxZBNtUuH6TrEnR3MXyE+HyjaajwEtR/FkNhjEDefczQrsgB94j16sP+lkcasv9BIKd XIQ+RWx7gj+gjHgRrqLHSDXhkzmf/GI2yvJM5JCdJwk6Rvvcwhb5ETNduwikriWwfLqt 9a7bq0SSbBx8gmjrVpRq7NPzSmY9P2qOow9WGTy3QrCWW0FqcAFXZGdIImqSXa38CQKr 7z4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtYNPjYk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si35702488pgh.496.2018.11.18.04.03.42; Sun, 18 Nov 2018 04:03:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtYNPjYk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbeKRWXO (ORCPT + 99 others); Sun, 18 Nov 2018 17:23:14 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42117 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbeKRWXO (ORCPT ); Sun, 18 Nov 2018 17:23:14 -0500 Received: by mail-pl1-f196.google.com with SMTP id x21-v6so10519515pln.9 for ; Sun, 18 Nov 2018 04:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=b1ZYnLYN4ir4UacvVkD3Q/B6raJ1AexezCEPoh1Pabs=; b=qtYNPjYko/dnt43DWz6PBVj872BUtmlIVz3LcNxt9bB0G/E9ONzlE1jjswnx0Kbf9i BDBJ+HONKG2Lc8Yy8nEKFNs13fv85wQcKuigkYRpMSukmJw0iEWlTdsev8wXSqfEHLjU jk/bszc9TWBmm6nWG/B/0WKo/PKYhoC/XO6t2EkHfk4sl1EAMnLzN/oAmURsN9Rnvj8j 2Q/9x8NgN07alDXszwY3JD2i3TJTPHLyQecyo5G6zE/DAAxbdXV+7hi69kIFV3xjFyqr ruvBdXg9JYO33UJLVlrx04hEvwyEkKJb3/4pDxNj5k6AFmXhBd3oHkAKrxuwAw6f5ztZ TEGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=b1ZYnLYN4ir4UacvVkD3Q/B6raJ1AexezCEPoh1Pabs=; b=ECo4p/pLH7tt4KxCxVLaqPnLbqyxhdL+Fq2oWgmVRRBcTS7QdWx7Vin9s86aAVbk6D 32bB/4NWTByLQbo9qfK1EpJVOmWzAHtSq2glDqFGkUckhj4Wzy1C3i0VXOylnGDzt490 fqRsMWW8MlX5Q8FU+e5sCJACq9B2P1P658QuP7Mb2MP0LDsHxJ4+EiRo/pN3D5XIap4K mbD9WfAlzEm78aqLltGAU3aiIXjHH4s5YDiFFScKYHKYnIjFAYoescz1MD85TW2+ApGw G0dl0JYebLhRwdNPwf4FPmfSVX8hB1VSFcjVTJAaL4uuu7oR7tnxpoG5MgYSMLRZ/UWv OD8g== X-Gm-Message-State: AGRZ1gJmGJOWk4MHN46ozEFrcaSYpR3RmE2qPtJfx6oeiG9BWvZyuN2J 9RGwNzmr8bqfItaAwxmo24M= X-Received: by 2002:a17:902:8a88:: with SMTP id p8-v6mr17825829plo.94.1542542585694; Sun, 18 Nov 2018 04:03:05 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id i21sm36748495pgm.17.2018.11.18.04.03.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 04:03:04 -0800 (PST) From: Yafang Shao To: willy@infradead.org, akpm@linux-foundation.org, darrick.wong@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH] mm/filemap.c: minor optimization in write_iter file operation Date: Sun, 18 Nov 2018 20:02:18 +0800 Message-Id: <1542542538-11938-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This little adjustment on bitwise operation could make the code a little faster. As write_iter is used in lots of critical path, so this code change is useful for performance. Signed-off-by: Yafang Shao --- mm/filemap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8..a65056ea 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2881,7 +2881,8 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_flags & IOCB_APPEND) iocb->ki_pos = i_size_read(inode); - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) + if ((iocb->ki_flags & (IOCB_NOWAIT | IOCB_DIRECT)) == + IOCB_NOWAIT) return -EINVAL; count = iov_iter_count(from); -- 1.8.3.1