From patchwork Wed Dec 6 02:01:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10094839 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 326F460329 for ; Wed, 6 Dec 2017 02:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1920A29B25 for ; Wed, 6 Dec 2017 02:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DDB229B27; Wed, 6 Dec 2017 02:01:42 +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 70B8129B25 for ; Wed, 6 Dec 2017 02:01:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 004166E18D; Wed, 6 Dec 2017 02:01:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0044.outbound.protection.outlook.com [104.47.41.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFD736E18D; Wed, 6 Dec 2017 02:01:37 +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=cuSLk27x+899n+ZRGyVX8Dves8e3FKpfGetx1ml4/RQ=; b=1PjVBxXsJqDILGDr7JPGwPr17252TBoUw5QBzGJrnPMkf/0NlIFQ0YizioQnudygEHuy8eWtwh0XrL7x+J0QwgvKwKfVegl/AeF1N3ihO4R3MTNYZmp3BZymBB0KfXhSBac6PdmC5BjZukih7tswCNyqNjK7GYaJAe8b18JuWFw= 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; Wed, 6 Dec 2017 02:01:34 +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; Wed, 6 Dec 2017 02:01:34 +0000 From: "He, Roger" To: =?utf-8?B?Q2hyaXN0aWFuIEvDtm5pZw==?= , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" Subject: RE: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 Thread-Topic: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 Thread-Index: AQHTbchB/DsETuFtw0uI2NjzqZSEsaM1kDoQ Date: Wed, 6 Dec 2017 02:01:34 +0000 Message-ID: References: <20171205125452.7546-1-christian.koenig@amd.com> In-Reply-To: <20171205125452.7546-1-christian.koenig@amd.com> 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:4KxoShVIFVNeTOqQ4LzLdBWhq/twAQqU3o0mk58NXb72z7+cVSLGiFaM+siH3qX82vkXZkEeJK87Uy9fNxMQgWWvP3m8D/k22+Twg1CgSUIwmZUij15oVkmDgel9S3daowfRKf7lpmZaPPoZGyKpWdgUJpRRfvWubcJtLGUBWsKP8cvOb8qWz653EWvp8m8j2tSmg5bxWehTNAtlme2qI9lK2T8bApG8kgKWb9CQwgu+R0YIwDd/t7Sljb3WD9tJ x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 3d636908-74e2-422d-17d9-08d53c4d4756 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)(3231022)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(6072148)(201708071742011); SRVR:MWHPR1201MB0127; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR1201MB0127; x-forefront-prvs: 05134F8B4F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(346002)(366004)(13464003)(189003)(199004)(110136005)(2501003)(316002)(101416001)(55016002)(99286004)(33656002)(105586002)(106356001)(6506006)(8936002)(25786009)(77096006)(478600001)(229853002)(2900100001)(74316002)(66066001)(53546010)(72206003)(14454004)(2906002)(6436002)(8676002)(81156014)(81166006)(76176011)(2950100002)(2201001)(3660700001)(5660300001)(86362001)(3846002)(97736004)(6116002)(7736002)(102836003)(6246003)(305945005)(39060400002)(7696005)(3280700002)(68736007)(53936002)(9686003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0127; H:MWHPR1201MB0127.namprd12.prod.outlook.com; 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) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d636908-74e2-422d-17d9-08d53c4d4756 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Dec 2017 02:01:34.6797 (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 Reviewed-by: Roger He Thanks Roger(Hongbo.He) -----Original Message----- From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com] Sent: Tuesday, December 05, 2017 8:55 PM To: dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; He, Roger Subject: [PATCH] drm/ttm: swap consecutive allocated pooled pages v4 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 v4: don't touch the loop variable Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b6f7ce286fb1..44343a2bf55c 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -958,8 +958,15 @@ 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) - pages[count++] = p; + first = count; + list_for_each_entry(p, &plist, lru) { + struct page *tmp = p; + + /* Swap the pages if we detect consecutive order */ + if (count > first && pages[count - 1] == tmp - 1) + swap(tmp, pages[count - 1]); + pages[count++] = tmp; + } if (r) { /* If there is any pages in the list put them back to