From patchwork Tue May 31 09:59:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12865248 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 01006C4332F for ; Tue, 31 May 2022 10:00:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCEEC6B0075; Tue, 31 May 2022 06:00:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2EC86B0078; Tue, 31 May 2022 06:00:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7CD46B007B; Tue, 31 May 2022 06:00:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A8B626B0075 for ; Tue, 31 May 2022 06:00:16 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7E57F2CC for ; Tue, 31 May 2022 10:00:16 +0000 (UTC) X-FDA: 79525592832.10.E56634F Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf27.hostedemail.com (Postfix) with ESMTP id 2069C4005B for ; Tue, 31 May 2022 10:00:11 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id v19so9456289edd.4 for ; Tue, 31 May 2022 03:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mIxGnBiNQH7wWhpTAOYvfGm3yBUdW2Lv8hSFkOKs0aA=; b=YDb0d+PyOKs210qCqYAFGBvUZTTS4RAIRhhK/d+QO9gshGdaDWgKspQVMQpG7nrtX+ TufVc/6A+Te4bjWf9pWyv6ntrZjNTvO1o8tYpzOoAdjIqo9Bklfzy8dXk7BYMrxpSM95 usfHUfKLh7JEKoG9wN5zLAoQm71wvfUxu+xCGMzIBHPjTBYFFRg/fQ8Bc1mbpWvV9bwY PR/pdpoW3OmlfWODJKjL9jIEkGs8hD/ZjjXmxLFGR2b/njvlb082VeR+rrGF1R55oj4p qQAdYumTKMLx79UKpj8YkktDQvBcFKlZvP9zcVhZ48lAtSdY31sMnKI1F4yE0kXKaL3w HsZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mIxGnBiNQH7wWhpTAOYvfGm3yBUdW2Lv8hSFkOKs0aA=; b=Pg3jUvEDYiXmeXhpFhJWDSmQIq8TUpOQq8wRTMSimzTWR44z/6zhFuPVTb5qLreaAo AWBZXkM3G9l4ErUTL870IE41Q3X9RfoQaK2h2oAyd8ORt2+Wmda0bU38tkp2QBuWzdPr Ele0+PhKEfHCStgkIE+rRBJOSmQGxeD1gc/5VEfjW+rJs6K2fKZe55Nb9Re0HuPJE6W6 e4aeUyMDoXyhA4D8V5fTEViuklDeqr7uO9EbAsibPJOV2OlUEiDZVXOXdNkeeKLQG1rY mwmZ8AbWAERrfMGVvIIzNMAla/XWfIfVrLJumGWBMkA033pF9kdy7XrwidaxXMJilUAN y5hQ== X-Gm-Message-State: AOAM531VeRaM69Mu4jKWspXYHvsjOPBEP/YSpw+Xfj9mlro4eBhjV77R vz76jhwTAt+k6mkV1H6BBAU= X-Google-Smtp-Source: ABdhPJym6XbAZzn9cN4OBs65hCeI931sSsPopVK1yV+b7qr9DjRRmdjRD8OGAyhyWkR+LhQlwkaGRQ== X-Received: by 2002:a50:8754:0:b0:42d:e92f:c924 with SMTP id 20-20020a508754000000b0042de92fc924mr902302edv.389.1653991214818; Tue, 31 May 2022 03:00:14 -0700 (PDT) Received: from able.fritz.box (p5b0ea02f.dip0.t-ipconnect.de. [91.14.160.47]) by smtp.gmail.com with ESMTPSA id r13-20020a056402018d00b0042617ba6389sm582062edv.19.2022.05.31.03.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:00:14 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: christian.koenig@amd.com, alexander.deucher@amd.com, daniel@ffwll.ch, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, hughd@google.com, andrey.grodzovsky@amd.com Subject: [PATCH 03/13] mm: shmem: provide oom badness for shmem files Date: Tue, 31 May 2022 11:59:57 +0200 Message-Id: <20220531100007.174649-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531100007.174649-1-christian.koenig@amd.com> References: <20220531100007.174649-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2069C4005B X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=YDb0d+Py; spf=pass (imf27.hostedemail.com: domain of ckoenig.leichtzumerken@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=ckoenig.leichtzumerken@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: qb3xf4g74wbxj9aidd63nw8q3cti5qfe X-Rspamd-Server: rspam05 X-HE-Tag: 1653991211-803968 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: This gives the OOM killer an additional hint which processes are referencing shmem files with potentially no other accounting for them. Signed-off-by: Christian König --- mm/shmem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 4b2fea33158e..a4ad92a16968 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2179,6 +2179,11 @@ unsigned long shmem_get_unmapped_area(struct file *file, return inflated_addr; } +static long shmem_oom_badness(struct file *file) +{ + return i_size_read(file_inode(file)) >> PAGE_SHIFT; +} + #ifdef CONFIG_NUMA static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol) { @@ -3780,6 +3785,7 @@ EXPORT_SYMBOL(shmem_aops); static const struct file_operations shmem_file_operations = { .mmap = shmem_mmap, .get_unmapped_area = shmem_get_unmapped_area, + .oom_badness = shmem_oom_badness, #ifdef CONFIG_TMPFS .llseek = shmem_file_llseek, .read_iter = shmem_file_read_iter,