Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp390794iol; Thu, 9 Jun 2022 06:03:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/TpVQqjQoeSKBQEYG/JaUJHq/VGOPzWPC9BKP+0FWGop3O+gautSlaZ1manHqfAYFn/3s X-Received: by 2002:a05:6a00:2310:b0:505:a8ac:40e7 with SMTP id h16-20020a056a00231000b00505a8ac40e7mr40383273pfh.11.1654779804987; Thu, 09 Jun 2022 06:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654779804; cv=none; d=google.com; s=arc-20160816; b=ePZBQGqpBQq7SwDsvesKByrd9ujd6iZgaKOrRGrPoEkxx8y0BUCJ6PRy0Q7C4WP5kW DLUbamY3B40gRh43Urw5cCbichk5M5eRUH4+h1o/p3OwuXwii/cZFpQzMCKuyQNwGLWu JmVL9yQwkiUKqUO+X//CHnrcvuojJckCpFok1dBDxuPQ3G/vkM9Xo0dcsQJvMSD+8BDc I3H9pW9YpSjDG6RIU0uWz+/TkEfZIQOCmz+QYx8yykWDhedKjPdk1XztMq2YVRxQox10 3NfRC/TvY4/8rgsXOh0ZQAAyWtSjA7L3Vvg6DJR6/cEiWgvSwbZecK7DLglrdKMV/vo4 aKDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=U28j2PjZN2oiqvKxhUnwyd/bN75hpBsh2AgbH09Uz7A=; b=Zs3sS4MWg98pJ2epMbbiTLgdMCUuEz+dsWmxeASIAZXCDckjOse3vZftNRPY1A3Yv4 lE2llDSjxiNIa3QbtV6z63fpRWP4f1rdsMbo4XtdYGNvx0xEENFn1riZcPdDKwE7Ue7e k5YSSa6D+ozmONxD5e3HtPhkzKYZuQ1mhI+hkRYOLYfNriOSaqXPZY1JR/aoIfS2Evmy cp58NuHjHKv69/9yvaePEOy+khbOd0IiAjRSE726K6AyRHHE8ZAtHekgwVDcCwQHerjr 6u+pKKi/0spYzYBUrCb69hvaySFck7P30mgYRoXPH0zJksSIlggctNldWH7Ata1yZ0wa imwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cFkohmjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a056a00238400b0050ad22888dasi22604432pfc.158.2022.06.09.06.03.07; Thu, 09 Jun 2022 06:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cFkohmjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242938AbiFIM5K (ORCPT + 99 others); Thu, 9 Jun 2022 08:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235182AbiFIM5H (ORCPT ); Thu, 9 Jun 2022 08:57:07 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE3A2BF9; Thu, 9 Jun 2022 05:57:05 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 7B10021F24; Thu, 9 Jun 2022 12:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1654779424; h=from:from:reply-to: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; bh=U28j2PjZN2oiqvKxhUnwyd/bN75hpBsh2AgbH09Uz7A=; b=cFkohmjy7k4OX9d1OaQPtTN9EE/zJV2ErpgiPH7m8blNWJJ6BBZeoEmEz449KI0rfzy2BA XVeJQYaCgUF2mN2YG6+08pn+iSIHSyBrXQeAga+1sko3yRfSLWaHAiur5hWq9muNl5oJnw q766pmidjn9XorGZeH2GHV38FRhBu+g= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3EEAD2C141; Thu, 9 Jun 2022 12:57:04 +0000 (UTC) Date: Thu, 9 Jun 2022 14:57:03 +0200 From: Michal Hocko To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Christian =?iso-8859-1?Q?K=F6nig?= , 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 Subject: Re: [PATCH 03/13] mm: shmem: provide oom badness for shmem files Message-ID: References: <20220531100007.174649-1-christian.koenig@amd.com> <20220531100007.174649-4-christian.koenig@amd.com> <77b99722-fc13-e5c5-c9be-7d4f3830859c@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <77b99722-fc13-e5c5-c9be-7d4f3830859c@amd.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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. -- Michal Hocko SUSE Labs