From patchwork Mon Apr 18 21:37:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 12817129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33B33C433EF for ; Mon, 18 Apr 2022 21:37:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2BAC8D0022; Mon, 18 Apr 2022 17:37:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DB258D001A; Mon, 18 Apr 2022 17:37:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A2DC8D0022; Mon, 18 Apr 2022 17:37:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 7A8EC8D001A for ; Mon, 18 Apr 2022 17:37:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 3FD168043E for ; Mon, 18 Apr 2022 21:37:24 +0000 (UTC) X-FDA: 79371311208.04.CE9DCA6 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf04.hostedemail.com (Postfix) with ESMTP id A2BDB4000B for ; Mon, 18 Apr 2022 21:37:23 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 721EB1F41D3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650317842; bh=zfBsf2RUnAkmYRtu6lmk/b8dTq1cQYpREmaCwhUzUEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAWUs7vw4rAUaK44h9j1spxZtioK1PD5dBNKcpMrBFLUfZtnXiyERNuSmsGNTgifP qXynn0eWhQhDs6NqUV1p/vW3vZTm6MsMKpZEGWXERcAiHNf+HTmsdVfjUn4WqC4QcM 8wGPp5ECkEQiq1QbyZnqu8NPoSsGr8GZauB/p9I7NyYyB5+8uat2QvFKDFofKiss4Q vC/B3RIy8nxVLuLa9SviblUvj9vHucP8c8PBoa0WIVJpUFUodYw3JVxgJY4rGcwI4M 5W8ALr9v1cClZWFab9exNQ/FDKFXXMAshyWEb/2aqVcWfojuOs0d8/wgeRyvpAUYF6 VBWTg6uDa9D5w== From: Gabriel Krisman Bertazi To: hughd@google.com, akpm@linux-foundation.org, amir73il@gmail.com Cc: viro@zeniv.linux.org.uk, Gabriel Krisman Bertazi , kernel@collabora.com, Khazhismel Kumykov , Linux MM , linux-fsdevel Subject: [PATCH v3 1/3] shmem: Keep track of out-of-memory and out-of-space errors Date: Mon, 18 Apr 2022 17:37:11 -0400 Message-Id: <20220418213713.273050-2-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220418213713.273050-1-krisman@collabora.com> References: <20220418213713.273050-1-krisman@collabora.com> MIME-Version: 1.0 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=WAWUs7vw; dmarc=pass (policy=none) header.from=collabora.com; spf=pass (imf04.hostedemail.com: domain of krisman@collabora.com designates 46.235.227.227 as permitted sender) smtp.mailfrom=krisman@collabora.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A2BDB4000B X-Stat-Signature: w4jnkezuhcpt1sam44x56jkd6benw58g X-HE-Tag: 1650317843-98130 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: Keep a per-sb counter of failed shmem allocations for ENOMEM/ENOSPC to be reported on sysfs. The sysfs support is done separately on a later patch. Signed-off-by: Gabriel Krisman Bertazi --- include/linux/shmem_fs.h | 3 +++ mm/shmem.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index e65b80ed09e7..1a7cd9ea9107 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -44,6 +44,9 @@ struct shmem_sb_info { spinlock_t shrinklist_lock; /* Protects shrinklist */ struct list_head shrinklist; /* List of shinkable inodes */ unsigned long shrinklist_len; /* Length of shrinklist */ + + unsigned long acct_errors; + unsigned long space_errors; }; static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) diff --git a/mm/shmem.c b/mm/shmem.c index a09b29ec2b45..c350fa0a0fff 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -212,8 +212,10 @@ static inline bool shmem_inode_acct_block(struct inode *inode, long pages) struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - if (shmem_acct_block(info->flags, pages)) + if (shmem_acct_block(info->flags, pages)) { + sbinfo->acct_errors += 1; return false; + } if (sbinfo->max_blocks) { if (percpu_counter_compare(&sbinfo->used_blocks, @@ -225,6 +227,7 @@ static inline bool shmem_inode_acct_block(struct inode *inode, long pages) return true; unacct: + sbinfo->space_errors += 1; shmem_unacct_blocks(info->flags, pages); return false; }