Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3476819pxt; Tue, 10 Aug 2021 04:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCTXjTi2d1ntTerVxNHvj9XddxGM6Z9SjcaxEP/iTTT6UYO6SBd/i4zCNcuLE99wZLIZc2 X-Received: by 2002:a17:906:7e59:: with SMTP id z25mr2212826ejr.26.1628595889143; Tue, 10 Aug 2021 04:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628595889; cv=none; d=google.com; s=arc-20160816; b=Ex34/MFdHttu7eUT16RBtePMYNK6rXk1Ft+YxY5AWnk8dSGU0/34QPvkb81kB+kxtZ fjcbAYETo+9gJ6Y8b3v1JGAlqi3VjqBkkMb6oZWPbSteerOH9EDnheZgoHH26g4dhywH x4PfVaDYAPvtnMGeFosrMnDHgZcLGt1FsQDhledKyCDGQ+1wc1Q/OTWiKbf/Lr19delV Hr/pIvSuKkFTMTZJaJP2XDjO1AU/Or04Hue0Mn61MHDaVquvonRBxtxYT4bgCTMNcALP mMrmwINADrbPKLO+438sEhuxzkzjYBtb9GaaLUq+nmuVFQTier1lEYszUBUplBvNOycq dTFA== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=cKbU9FcikmLQJ8ei5FqM01XsNg7Lhvb/CqBLRSs+e6Y=; b=q9vhbVE3elvNukEAVWGq2ym6fMeXsK4fd4otfiWgcMuYS2VbIEhHsi0wo66DAI7MdD 02s4g2TBXykvu22Z2YIuUbvoCCzWcbJIv1qmRDo3TwQWZCSGKXvXwAfGScngnjxPufwC SbSm5muD78xRUA/yrnrhRjPyUNQvNJOyppnR/a+vieQLA8/s+vWJdrShlGJ1jnY4yIu7 NDbV163e1SogVTdIKEwVpLpbAWPSY91EP9eUNbF3ZWLJEVvOqJuXlJveJpLDfdvlDjWl +29BGYjfrM8oNmU6HhZfoN2XOYFJxaq47aKF/STAts249bvD0X86bNGWZSm3wdKmcfsb h8TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=dyIuT2n2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar29si238022ejc.701.2021.08.10.04.44.24; Tue, 10 Aug 2021 04:44:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=dyIuT2n2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233709AbhHJIkp (ORCPT + 99 others); Tue, 10 Aug 2021 04:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232964AbhHJIko (ORCPT ); Tue, 10 Aug 2021 04:40:44 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792DAC0613D3 for ; Tue, 10 Aug 2021 01:40:22 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id h13so25148415wrp.1 for ; Tue, 10 Aug 2021 01:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=cKbU9FcikmLQJ8ei5FqM01XsNg7Lhvb/CqBLRSs+e6Y=; b=dyIuT2n2VcPiM/RBZyvglfDmYnDB6Khh/nbdE68r8gYpY/a2NOrDaGfZLTs1W/+53t vXS/cZ/tC1I9/7dqHtnrmgMvWpGq9dGx95D1TIug5tn0JH7x68v/1Ix3ehVQ3mzJinRI GUr9/F01AqBZbk8e0i4kbq2w26FwQ6BX+66Fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=cKbU9FcikmLQJ8ei5FqM01XsNg7Lhvb/CqBLRSs+e6Y=; b=rupN6doTvmAXoWJj6sQyVZ1lOzbxVJs+8zLuwOxLf5soFvvW8/KXICrQDWyweaqWEG CMSih42tYYpWGF5euY00xM0l9fbfUN0S4E4TBs0eQR/7Gde10VI6n9JHt0WisWKwmmEk LsLYk2zDpHbs8xy/tD8tLZzGwVwQ1iPMeHdx8mJXWHQhWpNkTDe7bjfvZzNptbUrwF6e /DKAvHhCHo55R/395oD+++u4RwGmS2qfxL6p0IIgszTr6e7YsMw1YL1fpUIz26rxB8BN VzUYwBV0V3okVZzlJOfVWVhYZFRnm7OY6Hrmai9VdvVHos2UvXUp41hh2b0N2ZvuPX4r 3ctA== X-Gm-Message-State: AOAM532Yfnn3z22udJNtWVkevwUI0keAjCDTrcPoUc1JY5mY7hdLZju2 bKC5Thk9FmZgA2+XfmtXYKeh8huyI8aTVQ== X-Received: by 2002:adf:ee4e:: with SMTP id w14mr29754692wro.15.1628584821138; Tue, 10 Aug 2021 01:40:21 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id c15sm22801342wrw.93.2021.08.10.01.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:40:20 -0700 (PDT) Date: Tue, 10 Aug 2021 10:40:18 +0200 From: Daniel Vetter To: Sumit Semwal Cc: Hridya Valsaraju , John Stultz , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , Christian =?iso-8859-1?Q?K=F6nig?= , linux-media , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , lkml , Android Kernel Team , Greg Kroah-Hartman Subject: Re: [PATCH] dma-buf: heaps: Set allocation limit for system heap Message-ID: Mail-Followup-To: Sumit Semwal , Hridya Valsaraju , John Stultz , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , Christian =?iso-8859-1?Q?K=F6nig?= , linux-media , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , lkml , Android Kernel Team , Greg Kroah-Hartman References: <20210722190747.1986614-1-hridya@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: Linux phenom 5.10.0-7-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 01:54:41PM +0530, Sumit Semwal wrote: > Hi Hridya, > > Apologies for the delay in responding. > > On Wed, 4 Aug 2021 at 03:09, Hridya Valsaraju wrote: > > > On Mon, Aug 2, 2021 at 7:18 PM John Stultz wrote: > > > > > > On Thu, Jul 22, 2021 at 12:07 PM Hridya Valsaraju > > wrote: > > > > This patch limits the size of total memory that can be requested in a > > > > single allocation from the system heap. This would prevent a > > > > buggy/malicious client from depleting system memory by requesting for > > an > > > > extremely large allocation which might destabilize the system. > > > > > > > > The limit is set to half the size of the device's total RAM which is > > the > > > > same as what was set by the deprecated ION system heap. > > > > > > > > Signed-off-by: Hridya Valsaraju > > > > > > Seems sane to me, unless folks have better suggestions for allocation > > limits. > > > > > > Reviewed-by: John Stultz > > > > Thank you for taking a look John! > > > Looks good to me; I will apply it to drm-misc today. Please don't, this doesn't really solve anything: - it's easy to bypass, just allocate more buffers to get over the limit - resource limit plan is cgroups, not hand-rolled limits in every allocator - the ttm "max half of system memory" is for pinned memory, to work around locking inversion issues between dma_resv_lock and core mm shrinkers. It does not actually impose an overall allocation limit, you can allocate ttm bo until your entire memory (and swap) are full. Christian König has merged a patch set to lift this by reworking the shrinker interaction, but it had to be reverted again because of some fallout I can't remember offhand. dma_resv_lock vs shrinkers is very tricky. So if you want resource limits then you really want cgroups here. Cheers, Daniel > > > > > > Regards, > > Hridya > > > > > > > > thanks > > > -john > > > Best, > Sumit. > > -- > Thanks and regards, > > Sumit Semwal (he / him) > Tech Lead - LCG, Vertical Technologies > Linaro.org │ Open source software for ARM SoCs -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch