From patchwork Tue Dec 5 02:45:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10092017 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 B096360327 for ; Tue, 5 Dec 2017 02:45:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9652028CBC for ; Tue, 5 Dec 2017 02:45:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 794DA28D70; Tue, 5 Dec 2017 02:45:43 +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=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 5093D28CBC for ; Tue, 5 Dec 2017 02:45:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A579D6E3E9; Tue, 5 Dec 2017 02:45:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0057.outbound.protection.outlook.com [104.47.37.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB51D6E3E9; Tue, 5 Dec 2017 02:45:39 +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=lXgvCIzJI4nqHFH0kwb4pIBGxqtep8svNYHL6cNN+U0=; b=kksrPZRTGQjPb+v7CcL0Lq34GKb4FEGKxPpG9rOpLlklMn2L3DcK+O0SR2uC9hbxZckVb6Tyh3QgGDqiTA1H9B75CJFEGD0ABubHUr+ROU1q5iBujyHjv4U8/EQHRgcvMwYPjTVbzO6Dx0TNYptIgvV/Jp05Iq/lGaoo+XjF+zQ= Received: from MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) by MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Tue, 5 Dec 2017 02:45:38 +0000 Received: from MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) by MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) with mapi id 15.20.0282.012; Tue, 5 Dec 2017 02:45:37 +0000 From: "He, Roger" To: "He, Roger" , =?utf-8?B?Q2hyaXN0aWFuIEvDtm5pZw==?= , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" Subject: RE: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages v3 Thread-Topic: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages v3 Thread-Index: AQHTbP3iqd3R3qCGZkmNrYhbD04BZ6Mz9h+QgAAUoAA= Date: Tue, 5 Dec 2017 02:45:37 +0000 Message-ID: References: <20171204124612.17591-1-christian.koenig@amd.com> <20171204124612.17591-2-christian.koenig@amd.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Hongbo.He@amd.com; x-originating-ip: [116.228.147.241] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR1201MB0127; 20:zKgYEbR40rEohEMKPz5QgkvFlKqanmFqJhWHsWgvvflsg6/7tmQBGaHpUWYCX6I4c06aWwA2XzEuz/5PYXK2l+daNKMjrNtcz3JM4hrzFjZIye35fJN8DWiwNj+I6azAYf5BwChrwttf0wKqEBicKo6HqF9S7bZ214D0JCjXMTb8XgfrrhO7c8tp+LcjrO3uFqzdognt4x7Vi65zhaxy4HNIZLkYWv2xX7mgzNFTgzOgWPol/yNgcmXU0v7Ysya3 x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(6009001)(366004)(346002)(376002)(39860400002)(199003)(189002)(13464003)(6506006)(8936002)(25786009)(2201001)(14454004)(55016002)(2501003)(2950100002)(478600001)(72206003)(105586002)(305945005)(106356001)(6436002)(966005)(68736007)(86362001)(7736002)(229853002)(101416001)(2940100002)(53546010)(77096006)(575784001)(39060400002)(189998001)(3660700001)(5660300001)(97736004)(33656002)(8676002)(6116002)(3846002)(81156014)(102836003)(3280700002)(81166006)(2906002)(76176011)(110136005)(54356011)(53936002)(9686003)(6306002)(74316002)(316002)(2900100001)(66066001)(7696005)(99286004)(6246003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0127; H:MWHPR1201MB0127.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: cf66f85a-230a-4c35-b73f-08d53b8a440d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286); SRVR:MWHPR1201MB0127; x-ms-traffictypediagnostic: MWHPR1201MB0127: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(217544274631240); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231022)(10201501046)(6055026)(6041248)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011); SRVR:MWHPR1201MB0127; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR1201MB0127; x-forefront-prvs: 0512CC5201 received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf66f85a-230a-4c35-b73f-08d53b8a440d X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2017 02:45:37.4505 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0127 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hold on, only Patch 1 is Reviewed-by: Roger He . For Patch 2: + list_for_each_entry(p, &plist, lru) { + /* Swap the pages if we detect consecutive order */ + if (count > first && pages[count - 1] == p - 1) { + swap(p, pages[count - 1]); // swap seems breaking the plist, after that iteration plist will not work. } pages[count++] = temp; + } -----Original Message----- From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of He, Roger Sent: Tuesday, December 05, 2017 10:01 AM To: Christian König ; dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org Subject: RE: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages v3 Series is: Reviewed-by: Roger He Thanks Roger(Hongbo.He) -----Original Message----- From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com] Sent: Monday, December 04, 2017 8:46 PM To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; He, Roger Subject: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages v3 When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page. v2: use swap v3: check if it's really the first allocated page Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 7c4d4edce0ba..da8a50f7c8fe 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -954,8 +954,13 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, r = ttm_page_pool_get_pages(pool, &plist, flags, cstate, npages - count, 0); - list_for_each_entry(p, &plist, lru) + first = count; + list_for_each_entry(p, &plist, lru) { + /* Swap the pages if we detect consecutive order */ + if (count > first && pages[count - 1] == p - 1) + swap(p, pages[count - 1]); pages[count++] = p; + } if (r) { /* If there is any pages in the list put them back to