From patchwork Tue Mar 22 22:27:36 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: 12789327 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 E5FB3C433F5 for ; Tue, 22 Mar 2022 22:27:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74F976B007D; Tue, 22 Mar 2022 18:27:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 700BE6B0085; Tue, 22 Mar 2022 18:27:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C72C6B0089; Tue, 22 Mar 2022 18:27:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 4DE476B007D for ; Tue, 22 Mar 2022 18:27:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F0F2BA5658 for ; Tue, 22 Mar 2022 22:27:51 +0000 (UTC) X-FDA: 79273460742.21.72FD0C0 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf10.hostedemail.com (Postfix) with ESMTP id 83D81C002A for ; Tue, 22 Mar 2022 22:27:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 63B681F442B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647988070; bh=zfBsf2RUnAkmYRtu6lmk/b8dTq1cQYpREmaCwhUzUEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4k6b5bLVXjtZTrPIpWLz2AWGVv7H7OYcYfgaVsJx4oNWe7mRga0FGDXi7+1fMjWy NnX7BipMzkyu5J7kHhVMw5nhrsIgqyMFPQ4vijQUcmeTARFbjzWDYrC26fifjn/U23 yRbMJrFwWKG/YDF76xyOMP+OKBqYMbk7i16uNiQtpIz9Mi5/EnUnWo844IhMjNssZy X7vEgi5MjjIiAZv18ekhgN6PJFGShAVr90c0iMR2thJYYzlLcRcNo5co4qFonaUqHz KT0RiBrkSUmqLSZG7JMCJtKm1aisGmS82Onv/gHesXFy7B3E9SfvV/D5bWBDGT9z7B 6XQg5x7mNA84A== From: Gabriel Krisman Bertazi To: hughd@google.com, akpm@linux-foundation.org, amir73il@gmail.com Cc: khazhy@google.com, linux-mm@kvack.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH 1/3] shmem: Keep track of out-of-memory and out-of-space errors Date: Tue, 22 Mar 2022 18:27:36 -0400 Message-Id: <20220322222738.182974-2-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322222738.182974-1-krisman@collabora.com> References: <20220322222738.182974-1-krisman@collabora.com> MIME-Version: 1.0 X-Stat-Signature: 7o4kzsj88dg4bqjpudzdy47wri3ixg5z X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 83D81C002A Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=X4k6b5bL; dmarc=pass (policy=none) header.from=collabora.com; spf=pass (imf10.hostedemail.com: domain of krisman@collabora.com designates 46.235.227.227 as permitted sender) smtp.mailfrom=krisman@collabora.com X-Rspam-User: X-HE-Tag: 1647988071-206565 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; }