Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp679753imu; Wed, 9 Jan 2019 04:43:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN5bArCVa766O3s3vkPgAXnHjeZF/qWVzAMuFU1hAq1RNqfB3Vdii2UWHwx8VcmAFymye6+3 X-Received: by 2002:a62:8985:: with SMTP id n5mr5885070pfk.255.1547037798886; Wed, 09 Jan 2019 04:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547037798; cv=none; d=google.com; s=arc-20160816; b=xsLB87qyyDDfxui/W5gEmsyxkbnqJewTwAqAhnA7ZG4LJkW/2TB+ln5Hg+AuNuRCiB pP8twVBsRWyVrQ92KEvc9Ssskpm/5tGfjBTPf2NqKUyoxv7I0Qx8ZVsudLGyDJioVSzY ras6G2ub/4uYovQ3m9iN0Cdc+Banz6vPhuh/jnVIo2AR/3c0HqqoY0c6hH89rcf1Znmy 7QZZnwdRqdzROyEt0g0+jlmHzeCWavO1R68TIiGg+8wRLPZonZ0nXLdKxwv7dVMtwjdh UDyIqGmX+0XJxZXClU7MGjkTIsUmHbuWa1FLn1gvd+MhBuIr2ZR4s4QdcNW//+Nb24uB A13g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=9S2UL6YPjRPiY8+WNR6DvKZzO3P0+ivl0h5qHhHkukY=; b=fKFlMvYqJ4x37YbC2uw0VhPYXALlYJSE5m+DO4EX0l/Jh/zb4pXDZT1ZQcjUKmGW2G C/vx4HZ7wYzZIKG8jYWomSdcY0wRl9bmOucehOTqK88cci7nJLdITASIFJVjd9JFG5ah 725LDby6HpJjUyoAcVyMf2XLvrX28QY/smcVMOjhRhTFJz6D+OQKGXGmi6DUwLBy+Ttg Wb92BK3ZGGZDASMqXSCasesoKlah/gDLrRK1tTJFQNxz+h4hOqwWP/e8rJQwHUiAKS7u +MGRlVTmKX1Uo32gSkcUmte5DFs4Xox8hhaVraJP3gO+XWowMY9nFpPD39V0Pi/XOCBl 38bA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s27si7153283pgm.501.2019.01.09.04.43.03; Wed, 09 Jan 2019 04:43:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730807AbfAIMUq (ORCPT + 99 others); Wed, 9 Jan 2019 07:20:46 -0500 Received: from relay.sw.ru ([185.231.240.75]:42354 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730761AbfAIMUo (ORCPT ); Wed, 9 Jan 2019 07:20:44 -0500 Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1ghCqZ-0004hI-Tg; Wed, 09 Jan 2019 15:20:35 +0300 Subject: [PATCH 3/3] mm: Pass FGP_NOWAIT in generic_file_buffered_read and enable ext4 From: Kirill Tkhai To: akpm@linux-foundation.org, hannes@cmpxchg.org, josef@toxicpanda.com, jack@suse.cz, hughd@google.com, ktkhai@virtuozzo.com, darrick.wong@oracle.com, mhocko@suse.com, aryabinin@virtuozzo.com, guro@fb.com, mgorman@techsingularity.net, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 09 Jan 2019 15:20:35 +0300 Message-ID: <154703643564.32690.8416317230641240199.stgit@localhost.localdomain> In-Reply-To: <154703479840.32690.6504699919905946726.stgit@localhost.localdomain> References: <154703479840.32690.6504699919905946726.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All page-obtaining functions, which are used by ext4, look to go thru pagecache_get_page() path, so all taken uncharged pages will be properly charged. Thus, we enable AS_KEEP_MEMCG_RECLAIM for ext4 regular files. Since memcg accounting requires page lock, and function generic_file_buffered_read() is the only of ext4-used functions, which does not care about FGP_NOWAIT, we make it use find_get_page_flags() and pass the flag. This allows pagecache_get_page() to use lock_page(), when it's possible. Signed-off-by: Kirill Tkhai --- fs/ext4/inode.c | 1 + mm/filemap.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index b1d7ddd70eee..2fc9e4a7c0db 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5065,6 +5065,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations; ext4_set_aops(inode); + set_bit(AS_KEEP_MEMCG_RECLAIM, &inode->i_mapping->flags); } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ext4_dir_inode_operations; inode->i_fop = &ext4_dir_operations; diff --git a/mm/filemap.c b/mm/filemap.c index 2603c44fc74a..46922003811f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2061,6 +2061,11 @@ static void shrink_readahead_size_eio(struct file *filp, ra->ra_pages /= 4; } +static int kiocb_fgp_flags(struct kiocb *iocb) +{ + return (iocb->ki_flags & IOCB_NOWAIT) ? FGP_NOWAIT : 0; +} + /** * generic_file_buffered_read - generic file read routine * @iocb: the iocb to read @@ -2111,7 +2116,8 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, goto out; } - page = find_get_page(mapping, index); + page = find_get_page_flags(mapping, index, + kiocb_fgp_flags(iocb)); if (!page) { if (iocb->ki_flags & IOCB_NOWAIT) goto would_block;