From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbeA3Lf1 (ORCPT ); Tue, 30 Jan 2018 06:35:27 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38562 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbeA3Lf0 (ORCPT ); Tue, 30 Jan 2018 06:35:26 -0500 X-Google-Smtp-Source: AH8x227b1ySilaH8KdmIQYruL3Pj009xt+1/vUWum3o4x5Ft8gyOiT8cttw2BMoGJmEYP+kLI1LzYw== Subject: Re: [RFC] Per file OOM badness To: =?UTF-8?Q?Michel_D=c3=a4nzer?= , christian.koenig@amd.com, Michal Hocko , Roman Gushchin Cc: linux-mm@kvack.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20180123153631.GR1526@dhcp22.suse.cz> <20180124092847.GI1526@dhcp22.suse.cz> <583f328e-ff46-c6a4-8548-064259995766@daenzer.net> <20180124110141.GA28465@dhcp22.suse.cz> <36b49523-792d-45f9-8617-32b6d9d77418@daenzer.net> <20180124115059.GC28465@dhcp22.suse.cz> <381a868c-78fd-d0d1-029e-a2cf4ab06d37@gmail.com> <20180130093145.GE25930@phenom.ffwll.local> <3db43c1a-59b8-af86-2b87-c783c629f512@daenzer.net> <20180130104216.GR25930@phenom.ffwll.local> <5c3f8061-d2d2-fa33-faac-cb95e0b2d44b@daenzer.net> From: =?UTF-8?Q?Nicolai_H=c3=a4hnle?= Message-ID: Date: Tue, 30 Jan 2018 12:35:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <5c3f8061-d2d2-fa33-faac-cb95e0b2d44b@daenzer.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.01.2018 11:48, Michel Dänzer wrote: > On 2018-01-30 11:42 AM, Daniel Vetter wrote: >> On Tue, Jan 30, 2018 at 10:43:10AM +0100, Michel Dänzer wrote: >>> On 2018-01-30 10:31 AM, Daniel Vetter wrote: >>> >>>> I guess a good first order approximation would be if we simply charge any >>>> newly allocated buffers to the process that created them, but that means >>>> hanging onto lots of mm_struct pointers since we want to make sure we then >>>> release those pages to the right mm again (since the process that drops >>>> the last ref might be a totally different one, depending upon how the >>>> buffers or DRM fd have been shared). >>>> >>>> Would it be ok to hang onto potentially arbitrary mmget references >>>> essentially forever? If that's ok I think we can do your process based >>>> account (minus a few minor inaccuracies for shared stuff perhaps, but no >>>> one cares about that). >>> >>> Honestly, I think you and Christian are overthinking this. Let's try >>> charging the memory to every process which shares a buffer, and go from >>> there. >> >> I'm not concerned about wrongly accounting shared buffers (they don't >> matter), but imbalanced accounting. I.e. allocate a buffer in the client, >> share it, but then the compositor drops the last reference. > > I don't think the order matters. The memory is "uncharged" in each > process when it drops its reference. Daniel made a fair point about passing DRM fds between processes, though. It's not a problem with how the fds are currently used, but somebody could do the following: 1. Create a DRM fd in process A, allocate lots of buffers. 2. Pass the fd to process B via some IPC mechanism. 3. Exit process A. There needs to be some assurance that the BOs are accounted as belonging to process B in the end. Cheers, Nicolai -- Lerne, wie die Welt wirklich ist, Aber vergiss niemals, wie sie sein sollte.