From patchwork Mon Jan 29 08:31:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10189409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1AEBF60212 for ; Mon, 29 Jan 2018 08:31:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0467128862 for ; Mon, 29 Jan 2018 08:31:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9D5728869; Mon, 29 Jan 2018 08:31:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DBFE28862 for ; Mon, 29 Jan 2018 08:31:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27B3C89DBF; Mon, 29 Jan 2018 08:31:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADB4289D99 for ; Mon, 29 Jan 2018 08:31:22 +0000 (UTC) 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=ZbKU4BJJasw/jGuGi9N14pa1C56RNYX+Iyxjo+bamrA=; b=qzejzz3N3EeTuDKxyLmg7wFzpv70ZD/quJ0dbhVVAdCqs30Ufz5DBJ41Tmb5JowzLlz1D3blZPK9zhf0W2s1lJ4cELNW1bZ6a2wVuFBvulZoJaepN6Fp4VPoH0iEm3WGB0MZ9C5/0SDx0eSxVyd0rv8oV8S0KJN4XZk5Xr6BaT0= Received: from CY4PR12CA0035.namprd12.prod.outlook.com (10.175.82.149) by MWHPR12MB1455.namprd12.prod.outlook.com (10.172.55.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 08:31:21 +0000 Received: from CO1NAM03FT043.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::208) by CY4PR12CA0035.outlook.office365.com (2603:10b6:903:129::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.444.14 via Frontend Transport; Mon, 29 Jan 2018 08:31:20 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.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 CO1NAM03FT043.mail.protection.outlook.com (10.152.81.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.444.13 via Frontend Transport; Mon, 29 Jan 2018 08:31:20 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Mon, 29 Jan 2018 02:31:17 -0600 From: Roger He To: Subject: [PATCH 1/2] drm/ttm: add swap_glob_mem in ttm_mem_global Date: Mon, 29 Jan 2018 16:31:12 +0800 Message-ID: <1517214673-30962-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 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)(346002)(39860400002)(376002)(39380400002)(396003)(2980300002)(428003)(199004)(189003)(53936002)(105586002)(316002)(50226002)(54906003)(97736004)(575784001)(86362001)(305945005)(16586007)(51416003)(2906002)(36756003)(104016004)(47776003)(7696005)(77096007)(186003)(356003)(26005)(478600001)(48376002)(336011)(81166006)(50466002)(81156014)(6916009)(5660300001)(59450400001)(6666003)(68736007)(8936002)(4326008)(2351001)(8676002)(106466001)(53416004)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1455; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT043; 1:WdNkXYvjhtM8c2atPO2X872Zs9ot15cahcSCTPfyh2YNAgYD+5hC5dF/TgfBN8qwHRJke0QL/pSMYUGf7LN4AkwEQkypCYiPG1p0w9DFtIpygmbfu6Kh5f0ksOGs9vMq X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fffeb4b-839b-401b-0d9a-08d566f2ac9f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR12MB1455; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1455; 3:KpTvF5FcChbHcWXbLvFEavb8WTD5AVzwh++BIm8xrWyIhELbd+wCcNFJ6PpyBz+cIqfN2S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QZZ5jCWQIo/88UjKdZM0RpjTjGS73bdNn8dVgbnGExySX9NqAjdHKIR4b7rqCtadZPWp52vYJPp5AJ7AkKrzQ7pt983nt5YlLe6u+xhIcyJJxGIdL5/R8Gf7yfnCkIR2UnZxRjDEuLutSZB7X64WBSY9GrPZR+5ZaChVpq0sUIOg91LeO6D01zjVcwsR5wXzKjpEGvTGob4YPCVB6QKJSTsWhwNxSrN5dw+vFKTP9aAkxq6XmytvdRQXCHBmqmO+/IbpzC6s04KiAUfoAO5L7A6BBu+dnakuXJYrN9KS6wxMp6MYdy0j1+p9vOwzoNdCy5fIE5rikqEw6sE+sA8hhrWEbg6sOHfDRX8AiIJSIB5qE7w8Vsef4DuR8R6KNSR/2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93003095)(3231101)(944501161)(10201501046)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR12MB1455; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1455; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1455; 4:xDvMWnMuJRhTopD2F2r3DCRTKeNgu6Ql6FHjVZ2P708UPQDCGwhbza4Il3cpsWO+lq9N6op3hdqYN/9unf7K/ecbSUynLt5p20fAwlE1+f7LRcblkPFP+MZwoFrEAE/8BPPGaEOnFAbX9JjJszWqXIwsHQCeB6B2J/jgezxjBhbBbXvGLlhAiKU5jov5rMPty4bedtpxBN84UHKKYe0emPABW6o1FhzfechCE6WPkD8u4k419b7HWybt5wvEanCEy8vQZ5qBO2FJx1EubXq3cKvDt374Ro11dCnreZS7hSOGz7Ecegx4oPbiaCuNh1QN X-Forefront-PRVS: 0567A15835 X-Microsoft-Exchange-Diagnostics: =?us-asc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lr9kQa701TnoWMdR/RJnTYDOW836N46e8aUQKb1yw/TpP9k0+xlHrOqU0fKApMpNnUjTY+ahsRt6PhGDuTDd+lko1s+bKWRvdbZCnKEo2bKZoNG5CKCWPp1lmsYEEI8R4NNs3QxhI/BFqTAQPjSXA6o/xUnjHVpRLas4smZSFC2MzFBRShyL/8viJ2cLYlytAvo6all SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1455; 20:hX+KqvhDar++1+WJN1g+ojeZ4RfiE+zxQQOhq0QSoYMBtSAfYqkHoAFV4yQGbxPVmlwMErdqXndTjAce5zCayTlH8x/mOsRr5U3gDVrSUR10So5WDqrzsX/pBEmQyRF7c7VHKddNEjxpbazoZVOxI+kLG/r273yDjM5mw2GrTxDQbq9Ox6DfniNDePWAy57tYRk9iIAFuDZk4UD4Isdd/IzxBKUTsv447FsZS4Wfq6NwFRPfMde5cNUHxiW26poX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 08:31:20.5141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fffeb4b-839b-401b-0d9a-08d566f2ac9f 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: MWHPR12MB1455 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roger He , Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP separate swapped memory account from zone->used_mem because swapped ttm pages can be flushed into SWAP disk/file under high memory pressure. add check conditon in ttm_mem_global_reserve to prevent triggering OOM. because if SWAP disk/file is full, all swapped ttm page would stay in system memory which can't be flushed into disk/file. At this time, any memory request will trigger OOM killer. v2: always get total system swap size rather than getting it once at module init time Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_memory.c | 24 ++++++++++++++++-------- drivers/gpu/drm/ttm/ttm_tt.c | 13 +++++++++++-- include/drm/ttm/ttm_memory.h | 2 ++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index aa0c381..06024ba 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c @@ -36,6 +36,7 @@ #include #include #include +#include #define TTM_MEMORY_ALLOC_RETRIES 4 @@ -183,20 +184,20 @@ static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob, { unsigned int i; struct ttm_mem_zone *zone; - uint64_t target; + uint64_t target, limit; for (i = 0; i < glob->num_zones; ++i) { zone = glob->zones[i]; + limit = (capable(CAP_SYS_ADMIN)) ? + zone->emer_mem : zone->max_mem; + if (from_wq) target = zone->swap_limit; - else if (capable(CAP_SYS_ADMIN)) - target = zone->emer_mem; else - target = zone->max_mem; + target = limit; target = (extra > target) ? 0ULL : target; - if (zone->used_mem > target) return true; } @@ -373,6 +374,7 @@ int ttm_mem_global_init(struct ttm_mem_global *glob) return ret; } + atomic64_set(&glob->swap_glob_mem, 0); si_meminfo(&si); ret = ttm_mem_init_kernel_zone(glob, &si); @@ -473,10 +475,14 @@ static int ttm_mem_global_reserve(struct ttm_mem_global *glob, struct ttm_mem_zone *single_zone, uint64_t amount, bool reserve) { - uint64_t limit; + uint64_t swap_glob_mem, max_swap_cache; + uint64_t limit, total_used_mem; + struct ttm_mem_zone *zone; int ret = -ENOMEM; unsigned int i; - struct ttm_mem_zone *zone; + + swap_glob_mem = atomic64_read(&glob->swap_glob_mem); + max_swap_cache = (get_total_swap_pages() >> 1) << PAGE_SHIFT; spin_lock(&glob->lock); for (i = 0; i < glob->num_zones; ++i) { @@ -487,7 +493,9 @@ static int ttm_mem_global_reserve(struct ttm_mem_global *glob, limit = (capable(CAP_SYS_ADMIN)) ? zone->emer_mem : zone->max_mem; - if (zone->used_mem > limit) + total_used_mem = zone->used_mem + swap_glob_mem; + limit += max_swap_cache; + if (total_used_mem > limit) goto out_unlock; } diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 9e4d43d..395cac0 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -177,8 +177,11 @@ void ttm_tt_destroy(struct ttm_tt *ttm) ttm_tt_unpopulate(ttm); if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) && - ttm->swap_storage) + ttm->swap_storage) { fput(ttm->swap_storage); + atomic64_sub_return(ttm->num_pages << PAGE_SHIFT, + &ttm->glob->mem_glob->swap_glob_mem); + } ttm->swap_storage = NULL; ttm->func->destroy(ttm); @@ -318,8 +321,11 @@ int ttm_tt_swapin(struct ttm_tt *ttm) put_page(from_page); } - if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP)) + if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP)) { fput(swap_storage); + atomic64_sub_return(ttm->num_pages << PAGE_SHIFT, + &ttm->glob->mem_glob->swap_glob_mem); + } ttm->swap_storage = NULL; ttm->page_flags &= ~TTM_PAGE_FLAG_SWAPPED; @@ -378,6 +384,9 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED; if (persistent_swap_storage) ttm->page_flags |= TTM_PAGE_FLAG_PERSISTENT_SWAP; + else + atomic64_add_return(ttm->num_pages << PAGE_SHIFT, + &ttm->glob->mem_glob->swap_glob_mem); return 0; out_err: diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 8936285..a273581 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h @@ -49,6 +49,7 @@ * @work: The workqueue callback for the shrink queue. * @lock: Lock to protect the @shrink - and the memory accounting members, * that is, essentially the whole structure with some exceptions. + * @swap_glob_mem: total size of ttm page which has been swapped out * @zones: Array of pointers to accounting zones. * @num_zones: Number of populated entries in the @zones array. * @zone_kernel: Pointer to the kernel zone. @@ -67,6 +68,7 @@ struct ttm_mem_global { struct workqueue_struct *swap_queue; struct work_struct work; spinlock_t lock; + atomic64_t swap_glob_mem; struct ttm_mem_zone *zones[TTM_MEM_MAX_ZONES]; unsigned int num_zones; struct ttm_mem_zone *zone_kernel;