Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3788421pxt; Tue, 10 Aug 2021 11:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS0qd7/m8k+y9ltvaLlBzWedPNgSL8zCT4mXNGviphXJAma42ZmQH0kLj9fLoQdm1DKAp+ X-Received: by 2002:a02:5107:: with SMTP id s7mr28643191jaa.65.1628619529971; Tue, 10 Aug 2021 11:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628619529; cv=none; d=google.com; s=arc-20160816; b=thjlv87Va8y1fKjvoYfN0vuby2Kb0dWx0fH8AaAq8tIsLop1ulQuPimawes4fPv1Aj Uucet7S/K6TSpgYB1G9m8XelDPt9RlMXX5JPKMS9GahOx3HihqtJUrDYTIUSF6fWOyB3 mLFHMvgZ6+hS2yOhkPA9KpkNenxfjICCVisIcnR5vP13k5JTOn7qlz5hZbguSP+Qooos q9lrSHTSO1F1DAmMlaJaznvrfAe+PSdAxXCGAj2g3RFeCI9fl7dUa/Y4fO72vMoJ0aji Q+6YGgNeDpSAKcROPYUIoX5UmzrdTNreVe0uTgFawl9Gvu512AYCKlG6e5VlZKg+f+dz ZuXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:to:subject:message-id :date:from:in-reply-to:references:mime-version:dkim-signature; bh=Z9ITGSDMGYjHXB8OwNKC53Rfsb5yUN6vdvBe2OSuloA=; b=hzLnWNAIKtQlLwj8Y+oVoRVGJq/aNQrW86Cs9/PdyUjkBOQJne8Eds6UGGgZxuBRQt f7IJuaHK8ILb/dvqzLSvAYuMsk4cmFR/i+QKSzLXrOz0VG0R7E60GR4wvpFFpeaLeDyK bfQFG40KFo+1DPfJHTLw6tSlOB71sumoYDHP2QATo/gM93/cjSNwAlgKHL+beocHpY9I vc6LF7OlTqREWvaMnkq4wGcgrl5ruslMnVFnU+TEg1jxn6y7AtgFdLOB44CvsTNF8Jd5 Ve1uOUA52hv1QOReyXaXJLCDChGu7Y+OWSMl4rzUmMhp0naEUiyke+NwU79M4bCYr9iX WV5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="OZNF/dI0"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si12370102jar.115.2021.08.10.11.18.36; Tue, 10 Aug 2021 11:18: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=@google.com header.s=20161025 header.b="OZNF/dI0"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237696AbhHJSRk (ORCPT + 99 others); Tue, 10 Aug 2021 14:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239476AbhHJSPV (ORCPT ); Tue, 10 Aug 2021 14:15:21 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35855C08EA4F for ; Tue, 10 Aug 2021 10:49:04 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id a201so37649323ybg.12 for ; Tue, 10 Aug 2021 10:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=Z9ITGSDMGYjHXB8OwNKC53Rfsb5yUN6vdvBe2OSuloA=; b=OZNF/dI0kLDLbyn3bsG/D44IWiklGxD6aKGryYNTGg3RhEOv3iUmlRTJ0N1fdVJMkL NeV4VitUPkU2mCH2gRyOZjw4SIp/7jhiBSA3mycw07zVKrO4AGsjkxW01R1NgqjtaWK7 nMky3Pw4dAdJR30D58pyzbt2gyi8gxZ7etn67AwtWKnCbqqMnEWPFp1bKXSLwV7GTnzK ppNkLm+nEw7bAh316KFYIM/CTmlMGgmEiGD3Oo6Y0gT3IL2GT3g6jccTSjGZEUoNE6yN m3ckLQvhk8RZcKnzbhF6NGGbsUhzM2UrbMm1PrMZEyf/3LKgmw+Ig3P7ApBYFaPtEJdq q0ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=Z9ITGSDMGYjHXB8OwNKC53Rfsb5yUN6vdvBe2OSuloA=; b=rvHhNLTfGR744ZHOg9ezMve5WUwFpKG6JEKuRWw6S6MB5Y4fGheqNzxb6tzq9IW9M9 d7JAGlHuZ8wA7pnDehJC2kHeqXQ3fBn4otCb5Ia3mL8g7cbe3ppJg5OokrWOpbL26ywx k98c08r5BQ6YvXoQHhqmhqE+KrCJ6c26aXC2/ZEc3i7toA9RR/CNIGDHrSSad7lcS7rR zV54AUtsiaCOLhfjkxRSC8G4Odo36dtDLuJBELZKgVPJTUZ04XJWff3n/ZWLELeHUAGu wci6byKYdB+84XS1iu2P4pcQSWUJSEo0GkxcDjad+mV0Zvp0LEHxbQ/saBz6S+1ZF0m1 P1zw== X-Gm-Message-State: AOAM532l20Ex09RLmV0pUoil2wyPi57nMMgshQ5SD1qYIViceB2QMiHM ULtTCJB43B+aG1hmJy+0aFDdTBUG8dIxF+gzdBslDQ== X-Received: by 2002:a25:4114:: with SMTP id o20mr42745132yba.330.1628617743255; Tue, 10 Aug 2021 10:49:03 -0700 (PDT) MIME-Version: 1.0 References: <20210722190747.1986614-1-hridya@google.com> In-Reply-To: From: Hridya Valsaraju Date: Tue, 10 Aug 2021 10:48:26 -0700 Message-ID: Subject: Re: [PATCH] dma-buf: heaps: Set allocation limit for system heap To: Sumit Semwal , Hridya Valsaraju , John Stultz , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , =?UTF-8?Q?Christian_K=C3=B6nig?= , linux-media , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , lkml , Android Kernel Team , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 1:40 AM Daniel Vetter wrote: > > 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 w= rote: > > > > > > > > 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 allocati= on > > > 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 aroun= d > locking inversion issues between dma_resv_lock and core mm shrinkers. I= t > does not actually impose an overall allocation limit, you can allocate > ttm bo until your entire memory (and swap) are full. Christian K=C3=B6n= ig 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 remembe= r > offhand. dma_resv_lock vs shrinkers is very tricky. > > So if you want resource limits then you really want cgroups here. Thanks Daniel and Sumit, that makes sense. Once the GPU memory accounting cgroups are ready, we should be able to set the limit using the same. Regards, Hridya > > Cheers, Daniel > > > > > > > > > > > Regards, > > > Hridya > > > > > > > > > > > thanks > > > > -john > > > > > Best, > > Sumit. > > > > -- > > Thanks and regards, > > > > Sumit Semwal (he / him) > > Tech Lead - LCG, Vertical Technologies > > Linaro.org =E2=94=82 Open source software for ARM SoCs > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch