From patchwork Wed Jan 9 12:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10753987 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 88FBD91E for ; Wed, 9 Jan 2019 12:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7802928ECC for ; Wed, 9 Jan 2019 12:20:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75F1C28ED2; Wed, 9 Jan 2019 12:20:48 +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=-2.9 required=2.0 tests=BAYES_00,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 EB32E28ECC for ; Wed, 9 Jan 2019 12:20:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6F8C8E00A2; Wed, 9 Jan 2019 07:20:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1DCC8E0038; Wed, 9 Jan 2019 07:20:46 -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 B34C58E00A2; Wed, 9 Jan 2019 07:20:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by kanga.kvack.org (Postfix) with ESMTP id 4777E8E0038 for ; Wed, 9 Jan 2019 07:20:46 -0500 (EST) Received: by mail-lj1-f199.google.com with SMTP id f22-v6so1752695lja.7 for ; Wed, 09 Jan 2019 04:20:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=9S2UL6YPjRPiY8+WNR6DvKZzO3P0+ivl0h5qHhHkukY=; b=QziM+8bTGwOblifny1JIGjKwaqQogMFgCvIrW/eQHmhK2mxFghl+vXm2OKZv160uuk V7ngqjfLt7IdrQFneJGrDAOYXO+4NHWes/QxGUpthDxqbp0tVRptKvEq1Jb100U1eVD+ TmecwCXjsO3GfgfyJXrMaJNvgmSsQIlgb5cO6qir3/73ncrFoiUT915F7tBIK3hRqD0b VexQgR36LQriMe6NLVbBKoeTyI0r453Gm1AwhLyOhMArUTj7SVRDHoa8qXt2b3qir4xN iRRMAudZ4RjjnP7P1tncffl/BbQ0QeUcIufvzuynr9b4tUR5RdO5EAAwUn7tSkUnEBsP 06Qg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AJcUukedcCgqrA95w7trm3EQEiuFt17s9O2dNH0NslOpPFOkS/BloyP0 0nUnqPmPL4EnEz3v/LNPk+ZfMn+Dmetsnf0GJqoEpyckruGUY1shisCSEuqgM7BSRH1XDM8pa3O d4Kz4E5btlS/kHvlSqsxY2VC6Gr45NQ/tMqmahBPqhGAbgaDpw8E6ITZc7Lx6tnJxzA== X-Received: by 2002:a2e:84ca:: with SMTP id q10-v6mr3244700ljh.65.1547036445712; Wed, 09 Jan 2019 04:20:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN6JY0YvKOJ50TGT5n8hF3+S1y/0M70iQRe48wmnvZfUJH4VvOxzM1ZfLbvCzRrCP1aPNK4/ X-Received: by 2002:a2e:84ca:: with SMTP id q10-v6mr3244663ljh.65.1547036444641; Wed, 09 Jan 2019 04:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547036444; cv=none; d=google.com; s=arc-20160816; b=d3UIdjHtGOmwUtUnQEp8hik5ZfA13oxwGZE5IUM7sOutgkLoc3rxngUByJ0Ea83v5k OBqtulLdYNhHWI3aAV4dwgatF4AluLIqByNJkWUm85cbQEhhV7yaXASGDPBLpeUNSOoX JQAb12e0Sbgm6LYYpjFEMlx06njfjbxPymDtiLtmGoDlrHBQzRI2t+d4I4wXOgQsg8ON ffWGzJfkF4/vU8F5FdgRm1JEO6hX+0+LU5OixBq4wyGgPt0ul4F53GHxAy7g9HSoTi0y 88ICAb1J/l0LZIhZUmjeRP1g4vELice8cCm0JbQGo6llj6lVXKwcPyIR28SSIa1KCSRL fQlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject; bh=9S2UL6YPjRPiY8+WNR6DvKZzO3P0+ivl0h5qHhHkukY=; b=kZMWSUI9v5VvRMDxBTyohu/rrjwEaBcVzyr1ebxbYX3GXkn0RYgVSFSMJbpSzN2RWC tEPNY4ZZzoiiswMp/8Q3qKh3ZRXtuaEZa4x29t3jKfUNFREhFmvs63pqox1OJ0Gw8xBX aW/69Ii0wU21b2+CkubNFiCzVxBmn/XNxJqhwgJB7U5cK+v/O0WMPRPb7LD+LIkSuYvF h94+zuYLHSTC0FfyXZonS9YIVnea/kOy5D0rG9k+Rq54Rd+IoBClXSHmHfAfTpVWaEyV QvWvSu1KriiQxWaqdClF0Hng9rgXmOzcQU3s7MtDC9lzZiNeZJyTPRwTV32Y9saNtbSx d9TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id u191-v6si73472439lja.171.2019.01.09.04.20.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 04:20:44 -0800 (PST) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com 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 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 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;