Received: by 10.223.176.46 with SMTP id f43csp1245734wra; Fri, 19 Jan 2018 08:50:20 -0800 (PST) X-Google-Smtp-Source: ACJfBosD5z8sD6nVvzCf67zTdNpiXbFM1skMk1Kj40bni5uguyikWhDuw7u2xs0NUNNDqWtgnku1 X-Received: by 2002:a17:902:6b02:: with SMTP id o2-v6mr1866837plk.248.1516380620126; Fri, 19 Jan 2018 08:50:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516380620; cv=none; d=google.com; s=arc-20160816; b=WSZmrJrK/7dd2oxOG+ZScHe9hSjSYgIhBpMwPIw6HKw4hxIq4JR5UZlY6ZnnmZgMNQ e0GgfyZMiXnhYdH4iCUC/KjcO3y2YOGwZlK4OxBvR5zIBZ5uPzw0ChBwfV/v0ioPr5x1 8iWtHpaaxBLIHvqQ0JmGYQYTICGEZ/usn0y8aF4T6Pmlca+btamkHLddXxnRuoSL8RY0 QKKwShh14o9Y8+hhk5YjIQeskW75Z3lb3AXu5lCcjhdBOwOkwj/xugrOXdsNOfamgEDn bNKnseUh5FzXf1ZHWFvbxnIOJe14WxzeTbxUo8CMJzl2fs1hbP6yP2/mZCZWpJCK0UE4 OmXg== 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:from:references:cc:to:subject:arc-authentication-results; bh=TxiwNCxcgNt32QPhA/udXMujb4eo5jdxKhQ2ps4wOog=; b=S2mWziZu3e8yIh9JGZBN3pZ5ZKj/TLPJ4U37C8lS2f0JTjjBmTjt6Cr3s5a2HO3+iP rkNwwS5Rpr5pkl903UgLwFeuC6QzkfXBce7phIgMioJvhKCBBJhBEmovHweqFLSED/kA mV3eumA6uuWvHt0bFGDyuSMoVkvI6p2CoxYpYI6sT9cJLTKFUFsEA5JUGDGTYqbc6EhP 4frmIIWvyD9QvGp322GuB/i+3D5Kk/0/67mBLVqfwI95b+ti8oEVnOnHh7NeTKPDnxbo SGe/a02rQyczFcXpD0V5BkkvF2TbJJ7YqjB3i5UhwTyWLhHMnm7oc/cVeDkEp2sAl74M nzHw== 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 h1si9519523pfi.35.2018.01.19.08.50.05; Fri, 19 Jan 2018 08:50:20 -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 S1756189AbeASQsm (ORCPT + 99 others); Fri, 19 Jan 2018 11:48:42 -0500 Received: from mail.netline.ch ([148.251.143.178]:34842 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756167AbeASQs2 (ORCPT ); Fri, 19 Jan 2018 11:48:28 -0500 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 28A802A6045; Fri, 19 Jan 2018 17:48:26 +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 iC1DggPrP8AQ; Fri, 19 Jan 2018 17:48:25 +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 2FFCC2A6042; Fri, 19 Jan 2018 17:48:25 +0100 (CET) Received: from localhost ([::1]) by thor with esmtp (Exim 4.90) (envelope-from ) id 1ecZq4-0001Rl-Bv; Fri, 19 Jan 2018 17:48:24 +0100 Subject: Re: [RFC] Per file OOM badness To: =?UTF-8?Q?Christian_K=c3=b6nig?= , Michal Hocko Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org References: <1516294072-17841-1-git-send-email-andrey.grodzovsky@amd.com> <20180118170006.GG6584@dhcp22.suse.cz> <20180118171355.GH6584@dhcp22.suse.cz> <87k1wfgcmb.fsf@anholt.net> <20180119082046.GL6584@dhcp22.suse.cz> <0cfaf256-928c-4cb8-8220-b8992592071b@amd.com> <20180119104058.GU6584@dhcp22.suse.cz> From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Message-ID: Date: Fri, 19 Jan 2018 17:48:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: 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-19 12:37 PM, Christian König wrote: > Am 19.01.2018 um 11:40 schrieb Michal Hocko: >> On Fri 19-01-18 09:39:03, Christian König wrote: >>> Am 19.01.2018 um 09:20 schrieb Michal Hocko: >> [...] >>>> OK, in that case I would propose a different approach. We already >>>> have rss_stat. So why do not we simply add a new counter there >>>> MM_KERNELPAGES and consider those in oom_badness? The rule would be >>>> that such a memory is bound to the process life time. I guess we will >>>> find more users for this later. >>> I already tried that and the problem with that approach is that some >>> buffers >>> are not created by the application which actually uses them. >>> >>> For example X/Wayland is creating and handing out render buffers to >>> application which want to use OpenGL. >>> >>> So the result is when you always account the application who created the >>> buffer the OOM killer will certainly reap X/Wayland first. And that is >>> exactly what we want to avoid here. >> Then you have to find the target allocation context at the time of the >> allocation and account it. > > And exactly that's the root of the problem: The target allocation > context isn't known at the time of the allocation. > > We could add callbacks so that when the memory is passed from the > allocator to the actual user of the memory. In other words when the > memory is passed from the X server to the client the driver would need > to decrement the X servers accounting and increment the clients accounting. > > But I think that would go deep into the file descriptor handling (we > would at least need to handle dup/dup2 and passing the fd using unix > domain sockets) and most likely would be rather error prone. > > The per file descriptor badness is/was just the much easier approach to > solve the issue, because the drivers already knew which client is > currently using which buffer objects. > > I of course agree that file descriptors can be shared between processes > and are by themselves not killable. But at least for our graphics driven > use case I don't see much of a problem killing all processes when a file > descriptor is used by more than one at the same time. In that case, accounting a BO as suggested by Michal above, in every process that shares it, should work fine, shouldn't it? The OOM killer will first select the process which has more memory accounted for other things than the BOs shared with another process. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer