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 1A957C77B6E for ; Wed, 12 Apr 2023 13:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 886726B0075; Wed, 12 Apr 2023 09:02:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 836DC900003; Wed, 12 Apr 2023 09:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FE6D900002; Wed, 12 Apr 2023 09:02:03 -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 5F40B6B0075 for ; Wed, 12 Apr 2023 09:02:03 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC2F8C0115 for ; Wed, 12 Apr 2023 13:02:02 +0000 (UTC) X-FDA: 80672751684.24.9C20F3C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf13.hostedemail.com (Postfix) with ESMTP id 91EFF2001A for ; Wed, 12 Apr 2023 13:02:00 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=pNLK7FQP; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681304520; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/X0WTWLoxqqFjJO52ZfP5BN4qu+yplrU+rRnlYdPoXk=; b=u9UcipgwM+BPQYD00slJJRjyzb+asusLxAbPYSkkdQKIep8xNDpiV4XGmPGauHnwkc4Aa5 5TUVfggM915eGjZw8VCDr4Mu9p91O5pCl+h59Cw5NUgP35ROo3BbvLF2gkwEZAzy1EG367 R1mfjE7X/KVwqtwGDrD3ChswS3r5tTA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=pNLK7FQP; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681304520; a=rsa-sha256; cv=none; b=qdRV67YyzBiURzZgszD+/z+hLvs98CPOmWEKciHgdQf/AtVtGpTX3B9THUMGmp4AalsHxs rP2H5hHSCaHGu9YD9127yXy7c6H9M3rKVv/Ua4UGTwTJTyh50yxP4Z2yaf1b6b+3k5xw+Y L9XZp7DynrztQwkyzVXEXDXeQECLfC0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0FB4C1F891; Wed, 12 Apr 2023 13:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681304519; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/X0WTWLoxqqFjJO52ZfP5BN4qu+yplrU+rRnlYdPoXk=; b=pNLK7FQP3MNurs33UmEEFf6ipceVPDMl74m5UhbRsSH0a/iritNuTydiQT5gP8wEGQrn+a LVHnZhnknQonAvy8O6vMlYEQCkcWCCvZxQtN0fHMz8eU51qKgvlhIIoG8Q/7y/MAlWBqT/ LHHCcNwr5W1rJ2lyRe+l3c6e2H+ZhFw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DCE85132C7; Wed, 12 Apr 2023 13:01:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +nPIMsarNmTdaAAAMHmgww (envelope-from ); Wed, 12 Apr 2023 13:01:58 +0000 Date: Wed, 12 Apr 2023 15:01:58 +0200 From: Michal Hocko To: Jaewon Kim Cc: "jstultz@google.com" , "tjmercier@google.com" , "sumit.semwal@linaro.org" , "daniel.vetter@ffwll.ch" , "akpm@linux-foundation.org" , "hannes@cmpxchg.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "jaewon31.kim@gmail.com" Subject: Re: [PATCH v3] dma-buf/heaps: system_heap: avoid too much allocation Message-ID: References: <20230410073228.23043-1-jaewon31.kim@samsung.com> <20230412085726epcms1p7d2bec2526e47bd10a3b6ea6a113c9cc3@epcms1p7> <20230412094440epcms1p445319579ead0d0576bb616ebb07501b4@epcms1p4> <20230412113759epcms1p8cb15b54e3a96c7616419cb030d16f804@epcms1p8> <20230412123532epcms1p23092e51df04b3fb4e18e90b324ebcaa4@epcms1p2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412123532epcms1p23092e51df04b3fb4e18e90b324ebcaa4@epcms1p2> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 91EFF2001A X-Rspam-User: X-Stat-Signature: 1mdgnwifg41gh9yj8wxpu5guj3k68ggz X-H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l6+/Ks6I9Xx6gkXoli4pBXLm31f9iXI6QePy+WTVR1uWl1j3r6cSYqEIQgR7LRv239N4xPzSDAtyed91V+6b2yDSk6ANzpJo89jt/oTCQm/VE/VjeSeJ5F86CZSzF/KNfFt47YqijhdDhuaQWdR3fP2KkhL13hPa8n9nMXi9HK4cvm+Nyw5kLSmG4kxcqw3eavyNYfB+nGVMOqjIMfawEeverUzQCTYlX1hlNNoycrHo4eO4wUjrAbuy5wqPrVaKP9HETC2+c1zw9t8kI2xczokJBo= 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: On Wed 12-04-23 21:35:32, Jaewon Kim wrote: > >On Wed 12-04-23 20:37:59, Jaewon Kim wrote: > >> Limiting dmabuf memory may be required. But I think there > >> is no nice and reasonable way so far. > > > >If that is really the way then the patch doesn't really add a big > >benefit. It doesn't really prevent OOMs (or panics due to OOM) as the > >allocator still allows to consume arbitrary amount of memory. The > >provided check is not able to tell between buggy and legit calls. > >-- > >Michal Hocko > >SUSE Labs > > Yes it could be. Though the buggy call is blocked by totalram_pages check, It seems our definitions of buggy differ here. I do not see much difference between totalram_pages +- PAGE_SIZE (or any epsilon for that matter). Both would put the system down to its knees without a way out other than panic. > mm may suffer memory shortage due to the huge memory consumption through > dma-buf system heap. We just hope Android LMKD or oomk kills the memory > hoggers prior to oom panic. You seem to be missing an important point. If the global OOM killer is not able to find a victim the LMKD or oomk are highly unlikely as well (unless they ignore OOM_SCORE_ADJ_MIN). > IMO if possible mm should be able to track the dma-buf size as stat in > mm_rss_stat for each process. I do remember some proposals from the past and IIRC the main problem was how to attribute those buffers to the actual owner. I believe I have give you some arguments to consider. The rest is up to you. As I've said I do not have any stakes in dmabuf. The patch itself is not actively harmful, it is just adding an illusion of a fix while it doesn't give much. -- Michal Hocko SUSE Labs