Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp926524rwl; Wed, 12 Apr 2023 06:10:24 -0700 (PDT) X-Google-Smtp-Source: AKy350aVih2CpDWc926wHCg91MgYh7+TrLtmoIoIAScrcePj2s9c5fhCYT00cIbRSRu//GKvfR93 X-Received: by 2002:a17:90b:1c03:b0:240:d8a:8d24 with SMTP id oc3-20020a17090b1c0300b002400d8a8d24mr22832550pjb.4.1681305023957; Wed, 12 Apr 2023 06:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681305023; cv=none; d=google.com; s=arc-20160816; b=eyBPrb2Xipw8eL/gS9T7PLRNSE2871d7G7cgO8lRuxXquvIsrl9Cqcp9LS2+nr4Ujo nA+Fcr8B7A65eFQqB+PuflQakwm/AddK78gkyLhszumbEGA+HDfPgwbGlbK1xWdrybZh ZBCZCNmw0Ly5fGVKOlh3CQGkY1K3Xm4e2mNsiCXmv+wD5ySIEmdH2OvT7da9Zcm8dp/u CBuzorLOqXhc7b6WrkNK+yYK2j9ZrjjillGpQ3vLdD65LReNWgFJOdVELiyhDDFF+z97 02GZLQPPPJLZRebMwRKjwEKqExR8G7EVosdAX0eyi4Gjf3fwQOllC9XmMiUqh2CX4krF AxiQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/X0WTWLoxqqFjJO52ZfP5BN4qu+yplrU+rRnlYdPoXk=; b=yqkn/MQeC5fCdEV3ShAtAsQlCJzOLuOBd8giv2QN79JtwVyDrAzqS7qteG/tEk4LBh DG7pUSAxy+tX8Wu66Khb5Mn/DTw6tE6Z7LdMvYErhNdGB7OCTei4f7sdknN4Eh36jMez lrFnDm1LaFdr6+uyV+awFTiVMN4Kukxa0o76m/Z4Hl/RrhyF7vyBDgwu+wp3XGQ2/CMD 1HR1SSFFMW1i+JnP9ahvtgwo/KG0x8XxvhW3pGNgI0bwmsjXRN8Y6rZ/bXGL/O6/wmkA lGFXDCSuRWHGVNOdKaVq8V+PgcPVECtQ/qoZY0nXrvhOHLem/ATCThkO8sQCjm9HYE4Q UBcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pNLK7FQP; 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 fh1-20020a17090b034100b0023670bc014dsi1850984pjb.110.2023.04.12.06.10.11; Wed, 12 Apr 2023 06:10:23 -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=pNLK7FQP; 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 S230130AbjDLNCN (ORCPT + 99 others); Wed, 12 Apr 2023 09:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjDLNCL (ORCPT ); Wed, 12 Apr 2023 09:02:11 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577624C1F for ; Wed, 12 Apr 2023 06:02:00 -0700 (PDT) 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-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,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 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