From patchwork Tue Dec 5 02:00: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: 10092007 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 20FBD60327 for ; Tue, 5 Dec 2017 02:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FD972899C for ; Tue, 5 Dec 2017 02:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E41428A10; Tue, 5 Dec 2017 02:00:46 +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 AF63A28B7A for ; Tue, 5 Dec 2017 02:00:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC6DE6E3E1; Tue, 5 Dec 2017 02:00:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0069.outbound.protection.outlook.com [104.47.32.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6474C6E3E1; Tue, 5 Dec 2017 02:00: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=+OfhKorWGefJ/o89E8AgwvKJPk1M2yzi+hygpZqq02k=; b=BcO97ZtBB41NiZL/Eu9W0t/x8+I2oy7kSsRb2MNc/2xHhq4SeL8aOKaCBCJeI1zpTAniZtqB3VUPrNPfDN3hkimoJNsLEvil4F1KniZ1igINXqw50oCpm1fZZIW0Xo2WjhSEFDj1eM0248nQbTrzUfW/JZbZEdcEt4R5S/BBqwE= Received: from MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) by MWHPR1201MB0125.namprd12.prod.outlook.com (10.174.98.140) 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:00:35 +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:00:35 +0000 From: "He, Roger" To: =?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+Q Date: Tue, 5 Dec 2017 02:00:34 +0000 Message-ID: References: <20171204124612.17591-1-christian.koenig@amd.com> <20171204124612.17591-2-christian.koenig@amd.com> In-Reply-To: <20171204124612.17591-2-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; MWHPR1201MB0125; 20:11nMzVG8eUcOFRrRm66mSLTQyRPrvK8jMzfvAodIUvrzRQsQr2hK3bTW7D/1PAr1J3fkQZLrI8+fGOqUivrb2y8BNbVnN7L3h4I18aN3upJZXAPtEIfYGcXGPtQETlwdDs4tag5hqYO90Q2WniF7Zg3e+gbuuSC7saOaIHAgahDRqe3s8gHUCDenQENg2HvZuN9n3eHzCSWBpq/AtAWlqbdGSPkNaSj0pX+SwrlJzue/ZwOXyFG1YSw+5kMo/LJR x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 32c31374-f00f-4f67-4a6d-08d53b83f95c 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:MWHPR1201MB0125; x-ms-traffictypediagnostic: MWHPR1201MB0125: 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)(8121501046)(5005006)(10201501046)(3231022)(3002001)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(20161123562025)(6072148)(201708071742011); SRVR:MWHPR1201MB0125; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR1201MB0125; x-forefront-prvs: 0512CC5201 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(366004)(189002)(199003)(13464003)(72206003)(6506006)(575784001)(101416001)(9686003)(3660700001)(77096006)(53546010)(229853002)(86362001)(110136005)(14454004)(7736002)(305945005)(74316002)(3280700002)(55016002)(33656002)(8936002)(189998001)(105586002)(106356001)(99286004)(2906002)(2501003)(316002)(3846002)(102836003)(6116002)(8676002)(66066001)(81156014)(81166006)(2900100001)(2201001)(478600001)(97736004)(39060400002)(5660300001)(2950100002)(54356011)(68736007)(76176011)(7696005)(53936002)(25786009)(6246003)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0125; 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: 32c31374-f00f-4f67-4a6d-08d53b83f95c X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2017 02:00:35.0779 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0125 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 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 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