Received: by 10.223.176.5 with SMTP id f5csp4082912wra; Tue, 30 Jan 2018 01:44:10 -0800 (PST) X-Google-Smtp-Source: AH8x226FkWLiXGcZU1stKntV0TWRRXiS3P0WwMj09h8nDel+pozlnPHtxQ1x12Uqe9Xi2Nj+sxq0 X-Received: by 10.99.67.133 with SMTP id q127mr23737640pga.365.1517305450161; Tue, 30 Jan 2018 01:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517305450; cv=none; d=google.com; s=arc-20160816; b=s/9VzPI0jRotXH5gsndZspnKIcsyb/37OGkhuzjm76Fv1Sb0ErylA7SpgLEiJDhIzr xcOWk/wcMBn16czn7VprxZsmjYNcAeC0f1+adXVrJ71zd/Oi0f1tv7gHc99OW+R+MeFv PIZqv6H/9Dykr2W+cXymSeEh0rYPEB7HrARk5CHGewiSDMa0kKENK1n9KEV9Fu8EeT9s oD/7W44toVPNjiVjVoUsmLt2CIn04022Y50U0EWNS7Wuwc93pGSDoWAEcL1EKeT6lflL xcFYE/zcUhNAelzjNKkABA7jgWi+PWfut7kFDYod3D/lE/uSjTPs/0AavpWuNt5kAHT+ Nr/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:cc:from:references:to:subject:arc-authentication-results; bh=SrfQl7esAUizLDMkqQXRH1M+ZymxZPLwo+50LI95Eno=; b=D6swdrji9aGZpMLkp7yesQuAYKw/R318tNZ+n1fwWmHc+oDZHHIclNSqvJ9oJrxt6b WHAhi6O0OSowIF+uudgS2OKhikZ9u4yOZBVgjKONqIJdMwcwVkOB0DxqKDYqZMdcGGgM nqPWpPEJcF3oCFTcBHOO0O3TdXYhKJHdUN3TUOT/25y9gnTVaaruk8vWJ38l9hWJGend X+44qQjPJhobDpAg+mamTJc3b5rhrJoPYsLN/ZthZIMnApgp32lGsPJh8DkxdEZUR5XO VJ/8U7UJ9HglsmzGlYDquIrWPjLnCcx0Ia26ywvMk7from4IXxuJzS/ETgCFbamR/1iW UA3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w66si2844258pgb.419.2018.01.30.01.43.55; Tue, 30 Jan 2018 01:44:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbeA3JnR (ORCPT + 99 others); Tue, 30 Jan 2018 04:43:17 -0500 Received: from mail.netline.ch ([148.251.143.178]:41800 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751801AbeA3JnN (ORCPT ); Tue, 30 Jan 2018 04:43:13 -0500 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 428732A6045; Tue, 30 Jan 2018 10:43:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id S4ftjRurhP2X; Tue, 30 Jan 2018 10:43:11 +0100 (CET) Received: from thor (190.2.62.188.dynamic.wline.res.cust.swisscom.ch [188.62.2.190]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 5DFF82A6042; Tue, 30 Jan 2018 10:43:11 +0100 (CET) Received: from localhost ([::1]) by thor with esmtp (Exim 4.90) (envelope-from ) id 1egSRa-0007T4-K6; Tue, 30 Jan 2018 10:43:10 +0100 Subject: Re: [RFC] Per file OOM badness To: christian.koenig@amd.com, Michal Hocko , dri-devel@lists.freedesktop.org, Roman Gushchin References: <20180118170006.GG6584@dhcp22.suse.cz> <20180123152659.GA21817@castle.DHCP.thefacebook.com> <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> From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, amd-gfx@lists.freedesktop.org Message-ID: <3db43c1a-59b8-af86-2b87-c783c629f512@daenzer.net> Date: Tue, 30 Jan 2018 10:43:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180130093145.GE25930@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-01-30 10:31 AM, Daniel Vetter wrote: > On Wed, Jan 24, 2018 at 01:11:09PM +0100, Christian König wrote: >> Am 24.01.2018 um 12:50 schrieb Michal Hocko: >>> On Wed 24-01-18 12:23:10, Michel Dänzer wrote: >>>> On 2018-01-24 12:01 PM, Michal Hocko wrote: >>>>> On Wed 24-01-18 11:27:15, Michel Dänzer wrote: >>> [...] >>>>>> 2. If the OOM killer kills a process which is sharing BOs with another >>>>>> process, this should result in the other process dropping its references >>>>>> to the BOs as well, at which point the memory is released. >>>>> OK. How exactly are those BOs mapped to the userspace? >>>> I'm not sure what you're asking. Userspace mostly uses a GEM handle to >>>> refer to a BO. There can also be userspace CPU mappings of the BO's >>>> memory, but userspace doesn't need CPU mappings for all BOs and only >>>> creates them as needed. >>> OK, I guess you have to bear with me some more. This whole stack is a >>> complete uknonwn. I am mostly after finding a boundary where you can >>> charge the allocated memory to the process so that the oom killer can >>> consider it. Is there anything like that? Except for the proposed file >>> handle hack? >> >> Not that I knew of. >> >> As I said before we need some kind of callback that a process now starts to >> use a file descriptor, but without anything from that file descriptor mapped >> into the address space. > > For more context: With DRI3 and wayland the compositor opens the DRM fd > and then passes it to the client, which then starts allocating stuff. That > makes book-keeping rather annoying. Actually, what you're describing is only true for the buffers shared by an X server with an X11 compositor. For the actual applications, the buffers are created on the client side and then shared with the X server / Wayland compositor. Anyway, it doesn't really matter. In all cases, the buffers are actually used by all parties that are sharing them, so charging the memory to all of them is perfectly appropriate. > 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. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer