Received: by 10.223.176.46 with SMTP id f43csp551876wra; Thu, 18 Jan 2018 22:03:47 -0800 (PST) X-Google-Smtp-Source: ACJfBovrlG/Mrt4YobNjZwAHuNDT1DKU12b0tZ3vJiKsd96cJF9O/o7pCuDf37P14EIwXDaLDHL+ X-Received: by 2002:a17:902:9342:: with SMTP id g2-v6mr1025859plp.34.1516341827057; Thu, 18 Jan 2018 22:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516341827; cv=none; d=google.com; s=arc-20160816; b=nf1Te0IHfHHrPZH+x3g9y4Cj+kn8Upxao0+4atPA7fVkd/PoAoPb2uBUcRA3QEp1UK vXLUr6dvNXg/madxq0n4A3b3NQK6QyBCvqJZwnLHAqoMOFs0ac3iQUegsS4wiuGR8HWa Oxdw33jAvn+yCxt2qQ+ZQ9RN0QObr0pAZMf6/09yvbsnPB0JcCbOrfffMhGG1kViuqeE j8uOuehYvMr/hfyE8pS+ZcJrtPXfjpMWl7LpsAS27l5fA40pffqSKt0NEPzTgLLV4AS7 NTE9tOm1Jg7hJEaZ9hcScJWiiBSKpd2W50sZX7bVOH4hbZ71VwjgNKAsENjkb6RFHtNE T1ew== 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=m41gDtFnekAh9hVdx67aoEYjnv4dflP9XgC2J81Jw/o=; b=AwoxdKJk9kU6jRaLbnO/YralZg+RizKnhW+ZWj5cTnxC3vIy3SL4fSr7HQmx3dCiRS xYvyYkHm1cR0AFBum4zY+m38lnmSwHCl9OjUC0fEYGZ2tVrTLFD8PtEYxHsI3N1hx3kS myTLukMaUYHZfPxEIDZgDt6zWuoFXPNp0Zm0xgiB1WUSKRsyJCY67OfbozX645yAUEAT zyjgEVKWKdLOYgzUtqak7kyW4yUJnZ64YOnofib63dj9gpu+Q9aIvz+CAoirBlI2Rz5+ vfryKgwIHOphSb4EBlfh5B5Bl7Gbh6P5NmeZN9Ec4w79FASvyGFRW4hR+dAvu2qsR/p8 b1Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=KQXYJu74; 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 x8si4427226pgp.381.2018.01.18.22.03.32; Thu, 18 Jan 2018 22:03:47 -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=KQXYJu74; 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 S1753332AbeASGBt (ORCPT + 99 others); Fri, 19 Jan 2018 01:01:49 -0500 Received: from mail-dm3nam03on0085.outbound.protection.outlook.com ([104.47.41.85]:58181 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752153AbeASGBn (ORCPT ); Fri, 19 Jan 2018 01:01:43 -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=m41gDtFnekAh9hVdx67aoEYjnv4dflP9XgC2J81Jw/o=; b=KQXYJu74vTG9K/v+q0DyT30HRFxwvKB6T3jiaoZd6xRY5cVYSMNK24eetNa2KmF/ZXWq3vtOtCC8hogK6s4xFuI+omxA7glgq5kks1SlU9JeSriVkpdeWdBz7deaAYK3ZQTI6xkdBNn8by6NxO4wXDHrkk3Mvbp3HULZuOKl+oU= Received: from MWHPR12CA0048.namprd12.prod.outlook.com (10.172.49.34) by BN6PR12MB1444.namprd12.prod.outlook.com (10.172.24.21) 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 06:01:40 +0000 Received: from DM3NAM03FT043.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::201) by MWHPR12CA0048.outlook.office365.com (2603:10b6:301:2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Fri, 19 Jan 2018 06:01:40 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT043.mail.protection.outlook.com (10.152.83.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.19 via Frontend Transport; Fri, 19 Jan 2018 06:01:40 +0000 Received: from [10.237.74.158] (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 19 Jan 2018 00:01:39 -0600 Subject: Re: [PATCH 3/4] drm/gem: adjust per file OOM badness on handling buffers To: Andrey Grodzovsky , , , , CC: References: <1516294072-17841-1-git-send-email-andrey.grodzovsky@amd.com> <1516294072-17841-4-git-send-email-andrey.grodzovsky@amd.com> From: Chunming Zhou Message-ID: Date: Fri, 19 Jan 2018 14:01:32 +0800 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: <1516294072-17841-4-git-send-email-andrey.grodzovsky@amd.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.34.1.3] X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(396003)(39380400002)(346002)(376002)(2980300002)(428003)(189003)(199004)(7736002)(58126008)(105586002)(16576012)(2870700001)(6666003)(478600001)(2950100002)(31686004)(16526018)(6246003)(110136005)(64126003)(59450400001)(31696002)(316002)(106466001)(53936002)(2201001)(356003)(81166006)(5660300001)(4326008)(81156014)(8936002)(305945005)(65826007)(77096007)(8676002)(575784001)(76176011)(72206003)(67846002)(83506002)(2486003)(104016004)(26005)(47776003)(229853002)(68736007)(23676004)(97736004)(50466002)(2906002)(36756003)(65956001)(65806001)(6116002)(3846002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1444;H:SATLEXCHOV02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM03FT043;1:YVt+/81TBSJspFcg2VhzZTR31fTajdKWwY6DswKPlhXqCwkyj4WOrwdin3Um5W1UX6Uj4TPUh+vo4PnKmIbdjoIRwxIxarnO6OIvDR9mpI+GtjRUXpi/OWKAQmkcRf+K X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7283b251-0be2-44e6-4553-08d55f021bc6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1444; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1444;3:wJura0TOEznOfwsDbR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6MpH8l7dmuXQW6vT09RwzdlEgWi/OBCeVP2of7errWwevPphvDS8T8auf1ELJ4dXt8rMGWvzF9AujdROo+f6Vfzf2uXdYibpXbT+RoO7cTQ+qGPhIReX/y0GDhxIxxH7SuRhaXIET90IjVFUQBPJelN8M4Ht3lvueUjUCJmovbupu8U/aVy69dDY8AJ/3u76LM/G1cqHVaNshyPpwo9s+o0CI9576W0tpRm/1alhyB41NqXUDLebUAkA6h9WHCbIk5syaBio1Xh3nNk88egoOqsOJoA7wUOjaCAI2UWCw/oZ+3FHuOAXvzfiZ4dKlK5DNeWmwyq5iYVUkdnN76oDldpNfleOL7+tXo3mMsNbGPz4T6/OCI3zkwxsxcGkuESTBC/o2bSO04QoDEnDusPpUK/bTWlPUcpS9K3yXZGtTUFdHh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(3231023)(2400072)(944501161)(93006095)(93003095)(10201501046)(6055026)(6041268)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BN6PR12MB1444;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR12MB1444; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1444;4:i3X6IDfhZn3AdwU3Nx08Ghls591mv4I0zPZQuYdoVE4nqL0LXvlVWxt4td5qKsegdGAlo9InptMYe5ZhXPWEGM20uZgubJXbA0XkXgJawhAXRarng9KaJ5tlWIr2ICwXbEn+Oy5/w83pb2FbNfq9uCFa1uIFXVey+kbY0aYOwEGGTC8ijASZb+uTJOxC87pwRo8UL0uk42Zq9DOZfnn4Ybzz1r15uYShYbWx7Iud/R6u0bijFbSp3kQZDyXsojS2YeYfcUp5ivfeqgcrgkILySfZiQ2AYYge7zrsA3bpcRh4K5qG3gn0GwSYG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8HXB/TmpllrlbxUvfLzQf2bQEx27DH6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1444;20:8E3JkgiUUeiXwatfgzGh1YOWxcWYNgaY99C8nrPfZl3OSjHl+elKCQiQWHu5HXVwmWw0iSYFkyWRv+V9UzFUwcQYKeKP/Rc47u8NYGyCIv1xP5OLFBxn6mDxSPycepe92kkRYOJySjfENxzCpAU5U36LZfn9y/uOmmkLQKNXtip0SQvw+BQA6XM5bjYpvTrbP2e9Pkuoy2ZC3IGbYai9x0omo90IxPGq8/bfb0iCdiHbX0jBI0xkw6WIbr49uj0G X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 06:01:40.1157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7283b251-0be2-44e6-4553-08d55f021bc6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1444 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年01月19日 00:47, Andrey Grodzovsky wrote: > Large amounts of VRAM are usually not CPU accessible, so they are not mapped > into the processes address space. But since the device drivers usually support > swapping buffers from VRAM to system memory we can still run into an out of > memory situation when userspace starts to allocate to much. > > This patch gives the OOM another hint which process is > holding how many resources. > > Signed-off-by: Andrey Grodzovsky > --- > drivers/gpu/drm/drm_file.c | 12 ++++++++++++ > drivers/gpu/drm/drm_gem.c | 8 ++++++++ > include/drm/drm_file.h | 4 ++++ > 3 files changed, 24 insertions(+) > > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c > index b3c6e99..626cc76 100644 > --- a/drivers/gpu/drm/drm_file.c > +++ b/drivers/gpu/drm/drm_file.c > @@ -747,3 +747,15 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e) > spin_unlock_irqrestore(&dev->event_lock, irqflags); > } > EXPORT_SYMBOL(drm_send_event); > + > +long drm_oom_badness(struct file *f) > +{ > + > + struct drm_file *file_priv = f->private_data; > + > + if (file_priv) > + return atomic_long_read(&file_priv->f_oom_badness); > + > + return 0; > +} > +EXPORT_SYMBOL(drm_oom_badness); > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index 01f8d94..ffbadc8 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -264,6 +264,9 @@ drm_gem_object_release_handle(int id, void *ptr, void *data) > drm_gem_remove_prime_handles(obj, file_priv); > drm_vma_node_revoke(&obj->vma_node, file_priv); > > + atomic_long_sub(obj->size >> PAGE_SHIFT, > + &file_priv->f_oom_badness); > + > drm_gem_object_handle_put_unlocked(obj); > > return 0; > @@ -299,6 +302,8 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) > idr_remove(&filp->object_idr, handle); > spin_unlock(&filp->table_lock); > > + atomic_long_sub(obj->size >> PAGE_SHIFT, &filp->f_oom_badness); > + > return 0; > } > EXPORT_SYMBOL(drm_gem_handle_delete); > @@ -417,6 +422,9 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, > } > > *handlep = handle; > + > + atomic_long_add(obj->size >> PAGE_SHIFT, > + &file_priv->f_oom_badness); For VRAM case, it should be counted only when vram bo is evicted to system memory. For example, vram total is 8GB, system memory total is 8GB, one application allocates 7GB vram and 7GB system memory, which is allowed, but if following your idea, then this application will be killed by OOM, right? Regards, David Zhou > return 0; > > err_revoke: > diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h > index 0e0c868..ac3aa75 100644 > --- a/include/drm/drm_file.h > +++ b/include/drm/drm_file.h > @@ -317,6 +317,8 @@ struct drm_file { > > /* private: */ > unsigned long lock_count; /* DRI1 legacy lock count */ > + > + atomic_long_t f_oom_badness; > }; > > /** > @@ -378,4 +380,6 @@ void drm_event_cancel_free(struct drm_device *dev, > void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e); > void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); > > +long drm_oom_badness(struct file *f); > + > #endif /* _DRM_FILE_H_ */