From patchwork Sun Nov 18 12:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 10687753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05DDF14D6 for ; Sun, 18 Nov 2018 12:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D909B29EFC for ; Sun, 18 Nov 2018 12:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA23529EFE; Sun, 18 Nov 2018 12:03:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63C5729EFC for ; Sun, 18 Nov 2018 12:03:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E435E6B1497; Sun, 18 Nov 2018 07:03:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF1EE6B1498; Sun, 18 Nov 2018 07:03:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D07896B1499; Sun, 18 Nov 2018 07:03:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 904606B1497 for ; Sun, 18 Nov 2018 07:03:07 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id s14so520312pfk.16 for ; Sun, 18 Nov 2018 04:03:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=b1ZYnLYN4ir4UacvVkD3Q/B6raJ1AexezCEPoh1Pabs=; b=PUhvR9k1wBkfiD/cDimSLNFtxL+9JAOIgB/skS7ffLrkWplsbqXhFkQb9ZSwAjCbAj 7NJWs1V3HafYuGj4W2/XVV1nDKQtEqE8CBicUxKtBMZpm46H+nYzVltCr/nYxeppusfO oDIsk7UViakayaAwdE0FKD6Ahu/Ek95529GVmQNOLZbcp28DsYs277qnxuQsYwvF8FT0 LROkmb0NS/tpEO3kGPNIUdvYH8bbWWlQu9wGX4pykvgFC+o+7Qn3dGvuejhf93Ifsogv 2kCfjenJIr9IOKcZz5GsXCs6EZFlg0mUbHJwfqTH7GvOLhMpP7/3xl0vETj9lAtcZQrf +aNg== X-Gm-Message-State: AGRZ1gKrSDCQPEe+q4kD79q1ArZHH449WAC/Z7/Yw9F4qL2nYyMxf9Vh hiAz2cYhAaaWrPVhUIqs89z40c+CF1grIxDt3rwKNqkjgn0DtFgO4lFPa+QA+BF8KcuiLFe3KHx JM0hE6QN9gm/G5MCDbGAbKybhSjwNGF0VJzksE0wrZG9l6G9NB9TLYtC9jvq6iPFG8rIgWIqlHN dAYhr/uEZNWI7rgIg42jqfFxX7rx0D6NiEPEvhc1gQkzXHjwMPdZ2kj6MyXVM5QccYwyP2FDQFJ gv7sdyXL16k76LALywEtu2NRVbOBtd+zp96NvUNTL65/fczsqZ7bkHWOlXPwX1uE6ZIrXhsqklM QTud24qm+8zo71LJHBVQFtS4DfBSM1NU2fzn6BrDXb1Ejzz/nevyVx+6ZriZ7qRGB465Wp2ABxR M X-Received: by 2002:a63:4384:: with SMTP id q126mr16300126pga.160.1542542587042; Sun, 18 Nov 2018 04:03:07 -0800 (PST) X-Received: by 2002:a63:4384:: with SMTP id q126mr16300075pga.160.1542542586072; Sun, 18 Nov 2018 04:03:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542542586; cv=none; d=google.com; s=arc-20160816; b=kIwjRbxv/u1JwaVtl3sqxMNuU0ye+sonf6IXZhubclyibHIVT/Cqbj42XWr/10L77V qtagD/ixESOyH3xouc1bVC15Zd24p6YBi9Zb7TZ6NYzeF5Clf55Rrs8hGTjFVAta42ih QtMs/MdTJdIW0x4TvuGIBklR3Lt6rqYxqzsqGBRK1fenwueroXF9iBPhB0Vc8hFxLFv9 mwkDc/GbH6aOiRxtMCU1hitVMLkrhPv9f15W5wj84o8UQLPA+o5XYUn8hZeD9HiXTboh MT9e/NwoqwKXBBkBpbcVc1kJWIi1gKrgWpekX+9Ry/IJCVijm1DxyHZboL9+EbpkYpid bPNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=b1ZYnLYN4ir4UacvVkD3Q/B6raJ1AexezCEPoh1Pabs=; b=Qq0Zuz/qXV2O654C0Ogk4qmQKp2WVqLPKdV+qAg1Hg6uugVRxtwucjtkspz+wqcqlF DaSLsvBslhSPPcszOfvCleZycsBfN7ZM/XJnI+yN2wdlqXD7gYujGLou+wFVlBXOScQu RVOZyFFBaJ2KGpQ6mp70cDF/aQBR9TGwoTY/lJO8GH+TJrYKzqhQWGlDp4vOwaI2QjiI 37BRc8KM4/JO/HFjbN2f52PnaJ9xMq0YZkMz+Uvg4nQ9ciIJrGLEHVqMFmYdAgpJsyG9 Si5x3byNJmuIGplAEjgJA2KUXzDJ+lZBXSblGbxTqCK3GghrGy9gXw51VqmWmCor9Pxl LQMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtYNPjYk; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w11sor19558975ply.14.2018.11.18.04.03.05 for (Google Transport Security); Sun, 18 Nov 2018 04:03:06 -0800 (PST) Received-SPF: pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtYNPjYk; spf=pass (google.com: domain of laoar.shao@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-Smtp-Source: AJdET5cDQ6utLkkHphvBu58J/8NIsRXNIlEGtv61ACddLjK1bPiOLlR6kHjvoQBAVNbBkJhCUltygw== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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);