From mboxrd@z Thu Jan 1 00:00:00 1970 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 37A4FC43334 for ; Thu, 9 Jun 2022 14:10:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F0C66B00AC; Thu, 9 Jun 2022 10:10:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 778FA8D001F; Thu, 9 Jun 2022 10:10:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CB238D0006; Thu, 9 Jun 2022 10:10:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 49E426B00AC for ; Thu, 9 Jun 2022 10:10:48 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 2206F121443 for ; Thu, 9 Jun 2022 14:10:48 +0000 (UTC) X-FDA: 79558883376.14.02C97E7 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf26.hostedemail.com (Postfix) with ESMTP id C082E140073 for ; Thu, 9 Jun 2022 14:10:47 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id b8so14701444edj.11 for ; Thu, 09 Jun 2022 07:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=mEtsDMb1k6CAhwW7ISC2TInxkibSNypnKownS0OQOzM=; b=mgrJ9hp/GfgwWN5tXJmnl8BnnEqXCAKpNGpam7MtrpYO0SI1hQovYwM1cGtHRSBW8N 8hwdKmACCRbdEVp3ztBxuOUpU8Lj8cWf+Kx+Z+HJz+f/NStxBiUuk3lNwo/iQqflxvTF InhPQenYDtubdWj0kzqQunKVK2VpuXe5lG3LqH359TPGOV1ya8aUubNqeEJm5slFN9UC s0l6wKpJdTKH6VEkOyvnAWu4FuxiRHTd1mmSc0t20a63BtaAauk73vDVGuMPaKxjSfDI ZF7BlODVAXy32IB8sffpp41YjC1ufolYJTK/mIyUwM1Gg4I4h8Te99MpvvqM5hnlFIwa jqMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mEtsDMb1k6CAhwW7ISC2TInxkibSNypnKownS0OQOzM=; b=WmElAiB1wWK/+v6PC9ymy8tRhyr9uvdnoK6ZcNeJQ948L4+l6WmuxUByjf//coDu3a q3050pV+Qn83hKptQteWg70YrN2ouvW2VIOoKyykF4nU1pkf38zJ5/8IVfI8SRwlUTow dPA1fFijQa6xrFqGDXqjSGr4W+yTEwRUAhSVnHCd+dcPoYquy/2caPLWggt3nd6CSBrL rQEvqm2JfY3okQFWhgC8MDMTgm3KvwI8W55aqeHgLZzR9UM2hefi7P/MJArx7IFnGCBM DEGYW70RDPHCPOiK974QsoK0RyDNXdCqzbydqbqjM4WcyPdB8+8n1iTx7Iw4cSviMvew COGA== X-Gm-Message-State: AOAM531RQ4Mkchi4TknLy4ZqglwRRPwLyNdXR336EI5s380Smg9ZIiQB cp2zCZEyDy1QBO53yI46hW0= X-Google-Smtp-Source: ABdhPJyeKHQqi9/0tzt/2RVsH3TlW5RXc5Nbx2kxhyDYn4Th+HmG5UQ3rIQ0Tdhh57D5z0Br/W8sFA== X-Received: by 2002:a05:6402:3291:b0:42d:dd03:cbb1 with SMTP id f17-20020a056402329100b0042ddd03cbb1mr44742813eda.268.1654783846479; Thu, 09 Jun 2022 07:10:46 -0700 (PDT) Received: from ?IPV6:2a02:908:1256:79a0:99ff:907d:6fef:f861? ([2a02:908:1256:79a0:99ff:907d:6fef:f861]) by smtp.gmail.com with ESMTPSA id q24-20020aa7d458000000b0042aad9edc9bsm14778769edr.71.2022.06.09.07.10.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jun 2022 07:10:39 -0700 (PDT) Message-ID: <26d3e1c7-d73c-cc95-54ef-58b2c9055f0c@gmail.com> Date: Thu, 9 Jun 2022 16:10:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 03/13] mm: shmem: provide oom badness for shmem files Content-Language: en-US To: Michal Hocko , =?UTF-8?Q?Christian_K=c3=b6nig?= Cc: 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, alexander.deucher@amd.com, daniel@ffwll.ch, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, hughd@google.com, andrey.grodzovsky@amd.com References: <20220531100007.174649-1-christian.koenig@amd.com> <20220531100007.174649-4-christian.koenig@amd.com> <77b99722-fc13-e5c5-c9be-7d4f3830859c@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654783847; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mEtsDMb1k6CAhwW7ISC2TInxkibSNypnKownS0OQOzM=; b=Gr5rUC8970Lvzc2DTfT2iAg/3u8rmHsaVAditvzr0wjEbkHkpBbrpGLOu26qCF4zlbpDgD 73HFyzW/t6aVadkjuib5RBc2EVItGugk3xcXD48f2Zgy6O9qS/fRMAOhuw6qnfwOkdq0K7 hmMMiRh1wkAp7PsdhnzoBS5RpyQj54k= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="mgrJ9hp/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ckoenig.leichtzumerken@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=ckoenig.leichtzumerken@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654783847; a=rsa-sha256; cv=none; b=JdAlvWRFpHSq9wjTWWUirMFgpeztd3FIHL/4CRW0PI/NOZunDqQ71+gXX56nHxAwVBOGx6 25rN8NKrUCS9MInPF3c9v6Dq/fFvokIwwmGjIZ8xud3QcgghS3KyoVxMNz+2vURoM5yNQJ pLH0Jgq7jEpAOA3lJEtfCIDIs3IyvJY= X-Stat-Signature: fy5sohodmujtokewats53wr4kk4tyhem X-Rspamd-Queue-Id: C082E140073 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="mgrJ9hp/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ckoenig.leichtzumerken@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=ckoenig.leichtzumerken@gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1654783847-996483 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: Am 09.06.22 um 14:57 schrieb Michal Hocko: > On Thu 09-06-22 14:16:56, Christian König wrote: >> Am 09.06.22 um 11:18 schrieb Michal Hocko: >>> On Tue 31-05-22 11:59:57, Christian König wrote: >>>> 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; >>>> +} >>> This doesn't really represent the in memory size of the file, does it? >> Well the file could be partially or fully swapped out as anonymous memory or >> the address space only sparse populated, but even then just using the file >> size as OOM badness sounded like the most straightforward approach to me. > It covers hole as well, right? Yes, exactly. > >> What could happen is that the file is also mmaped and we double account. >> >>> Also the memcg oom handling could be considerably skewed if the file was >>> shared between more memcgs. >> Yes, and that's one of the reasons why I didn't touched the memcg by this >> and only affected the classic OOM killer. > oom_badness is for all oom handlers, including memcg. Maybe I have > misread an earlier patch but I do not see anything specific to global > oom handling. As far as I can see the oom_badness() function is only used in oom_kill.c and in procfs to return the oom score. Did I missed something? Regards, Christian.