Received: by 10.223.176.46 with SMTP id f43csp887981wra; Fri, 19 Jan 2018 03:42:25 -0800 (PST) X-Google-Smtp-Source: ACJfBou03VnlCpe0j/bCi2rd6fghOsxXHrgw8eN3XWAs89f8BPi0nIaGqywISGR46T0X4s1ohR0Y X-Received: by 10.99.186.18 with SMTP id k18mr22790127pgf.7.1516362145252; Fri, 19 Jan 2018 03:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516362145; cv=none; d=google.com; s=arc-20160816; b=bGqr/8GBom/GOydowN2SXfGMa3ZD0rtyKavNvco4Mly8Hq9EJih3C6RwGrX2GCEf8A Dtji4f8/xmU0rwnco7kJ2UQCg4w9vxtxbcIxybN4awgoI2B2qEpQ8CrZ3gSGZsKAGWYq /dj7tcKy3XuGJUvyTgpfv5B/HN3/BrXzC+LSdMZSMAVDmS6ruETS8BMx/P/wwXdLeVxT ZPfgWTTB4U/uLt9PRlB6GhIFKflwWA7y6nh1ROBNaoGdjpc7G1Zsr4xcJsYc4ELE3sqV SMOicZQfxnV+jjJ75sNXVuBx2vJaXjaApGMiMtGYTbd9kfTeBFnjwtonAiVPtR2e+BgC P3OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=HWYdX4KoDHo+7z0i2Q7WfBACvAmlHU6FI5+0wUuE9WM=; b=jHAAQg0fNeoLO5X69J+VxGk5D3hZ8zDribz4Hl2+kntzRiXJDHoqzL+Cs7Y29gjLU3 Za3nUKQWWUOyYrQFU1SGjzSal86b701pxy6MN739CCx7F9z4jY7tUFtd44oAeyvaPUc+ IbHTlWysEqKFqr3j9TTpcGTRGTBSddL2iXkOemM5P+pqqXQHwsVEKE8Gqd5G3hQn0bY6 PJyaQ7m92kOBsJ2OfJsGj8a9XHVkY5U+iCP1GEIxjK8gBefSjLQnkEYuS11Zwnx0HjVu XnVJ5qJLzxOGNADcFsVEJ/5KUzpCJXR7ekVkJTqH7mqZZJZ7zt9qBO2fFvs7AnqFzmON SY9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=JkdDlo4g; 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 p72si9193435pfj.390.2018.01.19.03.42.00; Fri, 19 Jan 2018 03:42:25 -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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=JkdDlo4g; 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 S1755283AbeASLiN (ORCPT + 99 others); Fri, 19 Jan 2018 06:38:13 -0500 Received: from mail-by2nam03on0042.outbound.protection.outlook.com ([104.47.42.42]:31794 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754562AbeASLiG (ORCPT ); Fri, 19 Jan 2018 06:38:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=HWYdX4KoDHo+7z0i2Q7WfBACvAmlHU6FI5+0wUuE9WM=; b=JkdDlo4gLfbhEHdqyGkneYZawFzkcdVJF/bUcnpbT0YaBOxV4hv0xmvRax4yKbWXc/z1o5PfxTcSsGm1TDmXaLZC+f8E71VWebtMf+eh0YEQ+DBbTxCDcRXAZ6MS/krrbiZ3GKJ0HF6g13TQ3F7Rz+Vm0LQNgfV0pz8ZZjEh/rs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Received: from [IPv6:2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88] (2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88) by BN6PR12MB1298.namprd12.prod.outlook.com (10.168.227.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 19 Jan 2018 11:38:02 +0000 Subject: Re: [RFC] Per file OOM badness To: Michal Hocko Cc: Eric Anholt , Andrey Grodzovsky , linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, amd-gfx@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?Christian_K=c3=b6nig?= Message-ID: Date: Fri, 19 Jan 2018 12:37:51 +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: <20180119104058.GU6584@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88] X-ClientProxiedBy: DB6PR07CA0005.eurprd07.prod.outlook.com (10.175.239.15) To BN6PR12MB1298.namprd12.prod.outlook.com (10.168.227.148) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ec550fc-396c-4ffe-c2e1-08d55f311a25 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1298; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;3:RdwI9jxmNoV0/1PdAr14MvkZutxK8XpWmX26egkQ1NAXc8S/T1CZIweEOFUyj5juAv+tBeK0wZKzlzvJBr4Z6VgxhIZ9hKDokHR7DHJHNuY0FDqgafLi3wYeZVCrLnr+npuoG1QD16q1aRLnL70JcnQqffJ2QyTDL+gRhP4WRAtVV1dYAaDuLEWC3JyHne+PCDpiRkafJI0Xauf+PIknljUICt2SYMGTJWyy79yoliSn7iDtKd46HoA0UIR27o8J;25:yrORfft4tiHnxccOKBcfW7y++5lVqKRTDjcVzCDAyLB/YVEwDf26TUnS7EczhoN8FmSZumBCjmE6B1jMl76RaiwdXIsE+lK60Rcchiel3vj5y5JwEHKlGQBUQn/FenN/FRnKKaI5jti3s2PEWa6u8SQ1DigLVG3zL1JX0J7QDa6ZWSIy04wPskderY5DQ2hjqWD8jdLCiI3TvuSimmRqPkro6y8ZeKrokmL/+an4lFO6P/adDDmVcHHZZv7Ov8hBUmPjjC9vZGyfNGEVIZD6KnqQPJPWBDvc3fYOmvtSz3wIjMGDgd3k0H+ixmVPfs6y0OS2TC6cmXFGPKSp6T+CNA==;31:zfIEIsDdJ6OJRPEImoeqiWMP164cENozuhOlwtUWTlEEaKW/X2oBM2tUA6mM0uUB+PPp7q7mHQsz6u/Kr174x2BJp8vpL3aRqsUze575XMK2vHOyToRcsmQx5sdQ7Hge1tvhnJJR/lchK8NqTLqV1lSgv0JC8C64GwpTIc6YwGeMU+t8lK+OrHD2wtzUGprN64PMGisOS58rGQcQ+HKqk/bNB5l+e+9WM3F2Q2hkoaY= X-MS-TrafficTypeDiagnostic: BN6PR12MB1298: X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;20:r4JK4lokoeQQdkJOUlew8S6h2KoVJBdZRAFvWne2mwXl+dlel5JkECKm6kISKNpGIQnj2+AoJpnu6jnmTRfjs0FpTPF3YSDxjOxz0JWNIh1syQuM7tP/I2iJlPE/RBkdwfkL6uaQYwSEsTdxcr7WFOB+A7n2T2nbkouuJyNgjOo+nWNNm4wkeyd/CrygvckFwT0nvn9wA67yfmNHcrtHtQUgJBGWFND38XdzykCQOedPY5+gHVscqMijtpJVqq8+JYMmIMzVg8uOkzpjpCR0EX0ZxDtw8jGTS0dEDXKaZHWkcuqavdf7M2gnxbW1pWCIjWr6sTy7ixZW4bYM1tTAl4zOJPs7t1un+D1FLemTEhhLCvLw7BK+MBwOdcNNRU5HJqmSMCVKqZ3QY+JQdSSNJZPqqVtXKytlnx+gQ0xwRs3ngHsFb5AQlrkAXOIDdCeTBCrzsahtnYsfApDaAECBow/vfGkhVHKv15IwIC7t1uc8UyCTMXunZOZjyjkX7OPs;4:dnCUS9fPnguhO7c5MSxidMebQLl7c/Zh7e5zSpKrqCLn8HD7HIo0Um6R9kasTbJFqT6B46kAK6MdL7+X4pnQNNw5K5c0DCU7dsyzjH29QZ6IyD2bGmIkcKJFUseFyp92ZjIfAVnkky9LpYjR28eS/Vd6kVCQsPSd93vg4uVzuhMW2Jimp4jw01kXsoM60Y6DrmZCZ/f4j0NslQ1VRJ6I3drUhAkHhsRZYrGsR6PBIbPBuO3mGnCwhT1DowlnPSMfQ75LYMYX6UWC6CJm/l5FLwhF/HmA9ICKtzZts/0TFfO54tuVWo/s1pnlY97Azs/Y X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501161)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011);SRVR:BN6PR12MB1298;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR12MB1298; X-Forefront-PRVS: 0557CBAD84 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39380400002)(346002)(396003)(366004)(39860400002)(376002)(189003)(199004)(377424004)(51444003)(6486002)(76176011)(65956001)(106356001)(386003)(81156014)(65806001)(53936002)(81166006)(52396003)(23676004)(8676002)(2486003)(59450400001)(8936002)(52146003)(52116002)(47776003)(72206003)(478600001)(97736004)(305945005)(7736002)(36756003)(68736007)(105586002)(31686004)(93886005)(83506002)(86362001)(67846002)(64126003)(1706002)(6916009)(2950100002)(6666003)(2906002)(25786009)(6246003)(65826007)(2870700001)(6116002)(316002)(4326008)(229853002)(31696002)(54906003)(50466002)(58126008)(5660300001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1298;H:[IPv6:2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMjk4OzIzOllJZnk0YXhTWDJOZFgvUkJSK3BwYmpKYTB2?= =?utf-8?B?eE51eXk3aFRCaFVxRUd1WVBENlVDOERlbHYvM2FmRWVpUDNVVDlwUVZsb0kz?= =?utf-8?B?c1RFdFF1bjdySjNNWGpYaWhKcFQ1bUpqZXJiZnp3dlh1NlNFZmU2WUZmUG5S?= =?utf-8?B?cXpPbFFUa2ltaWR0UURRdzVuRVJ2Nmd1UkNIZzErU3B6bzhxMTJUNTFZdE1G?= =?utf-8?B?cW1qZ0VrdnpHeHh0U3AzYjFWRFBIVFd3ditxZkpsVzRYUkFhNFVxcXB1T1ZL?= =?utf-8?B?anBJNnRyeDlxZENmK2huSUJaOEFuaDU2VTZQbDZvdVFCcDg0TG1QalF5b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ajABzEcq+R3vstMzW3v5+y+aA2skARDGhisxq/Ut8T3Jg8frw1bsojFmUSpljNmgEVz50jIa+B5FKc2G7gNCdOpVaS0viVnfT2UNAiKkbPvnAQmhlUwi8Qg=;5:o2fzC90UORfNmLtJVTEVUFWRSXOsyUF/2LZjlDwBlj9NgCBRQhzmQONk4ypXNFrRriwipRrrAYgPne5Dp5288LnGV8Qwjtc043hNdT/g32Cz75UOUgBjQekaTkJjequWmN7H2P0ptEJ2lOA+Bdl8m2H4G30mDgdDQk8gQBvYUOI=;24:sREAHAeV0bpnrd3HL08lcXiJc+r22pqT8Esqd5pFABxPCX5vm9FVZDgBobMePWGQOwNMuFXPLatVm2IdrQb9gw7Pk5AGFN1FjdLLbYepjUw=;7:/aBCCfDDcJ3mMYopw4ijeuGXZ3pA16sgZTP/+Sj1OOeIpVm5XyjTcLVfvfwywsDN7Jv7QJvB/whDkc20oqSTwsN50pQPB5JMgO0TK5GVDNrhcOCUtyLFifbq9vjvnZKxeaM6+OIajTOw/0kh2VCyGSQq/DrjdUk216NEQiyy7TUdHhIGVElJ+lDNrCKGHxzu2PWcSr4Ul0uwM496UPK9eMGrwpeXuJLA4/ZaMHCHfxap8AdEknwiWPRW/G3Xzzhq SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;20:rk0mYJYITwj0mIU0ItVLuk/scZ7i9WOC7kueaZ8V3VfQB9wFiNQkiel+raRDcWVLSJ6gtudL1TZarWNOBQtSlKOZFe1xvJA7jcJ2peu0ABc9EZhouwwToIjHj6zMqRHjnDM8cMYEBFP1uhW1UGVzxlMq8vrvY6VNcb9BNVzCZjejoY9DlPg7lB8/3f/fjb1UtNevP+3I4bm6OrYnSPMqDdsQNtHRTDdeDyJ0URBiMTJUoKu7U3C9sS050neqcf6b X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 11:38:02.5761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ec550fc-396c-4ffe-c2e1-08d55f311a25 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1298 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Christian. > As follow up emails show, implementations > might differ and any robust oom solution have to rely on the common > counters.