Received: by 10.192.165.148 with SMTP id m20csp2253839imm; Thu, 26 Apr 2018 08:08:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoDUAskUX9Td4EQkU+7bp7k32jZiebsQ8AOSLa5KX2jSmPN8d9Fy6cuzD43hqwaSYdi5t/e X-Received: by 2002:a17:902:a70b:: with SMTP id w11-v6mr2815479plq.342.1524755312283; Thu, 26 Apr 2018 08:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524755312; cv=none; d=google.com; s=arc-20160816; b=RA8J8PvEhf8LqDkzjnuq2pKuzxe8d37eCAD8QkPEAB+jSS8nNmz7W73T+tOxjtrx8f s8KYCNQGy4kXSotUcjli+TXBW+B9wZzNXGMdpzWq/gxwcKPZUSvRfYYxhwEpBR7/s1OI kZYI/uI0tH/3Z59IvbIHZ/vbyXF1wP9X4DVNpJy7yoL2zjA8sWvuwtDmA2wG9b0+HXsv 5JL/92p35XwH/JFbECfkM6IAikT9v3fYrgMwwfkEeIYmddp1WqAEqItHlUnyB8Hnixz+ hz+NFAGVgj+qLOOTdE42cNPKxSSQKmhDmvHejW85eMeO09q5KweK85qhZfbm/04fYqoP RmXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gmXlOJUe5KL3mOWS1D+HkCeY8cM+3mIFpo5GB5g8we0=; b=HUsHAh4wsyUmN8/cn8QW0en6SaXMlPvDUwgXSG6RAqjSCR7Zp+jOI4gUpeINVJ3Ohf STu9u14rvlBqlPbQoy5m7QZC07h+x6MZk1WW9mKHWA0LPIZfRhs8KxTx8GkYA2zXQwdW O13lwutnN/Y9WbNp0CB28wm6whGUaXKeksfGe3K36lFsYhz4REikJT+L0amDFOIdWo+f f3SaJWqfIKROvHJLetEw/SK1PmFOxhP9Vb7BkgBYtsCZLblrInuxowpNP3xgkTYSggU9 04yBCO+iAKFBH2sn5rLcnP2Nn54LX/cc0oaQFBe8CnQiwnKjaN31f+RPXZS5bg9Wp6Tp gTZg== ARC-Authentication-Results: i=1; mx.google.com; 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 n128si15680729pgn.15.2018.04.26.08.08.17; Thu, 26 Apr 2018 08:08:32 -0700 (PDT) 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; 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 S1756637AbeDZPGY (ORCPT + 99 others); Thu, 26 Apr 2018 11:06:24 -0400 Received: from mail.netline.ch ([148.251.143.178]:56507 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756204AbeDZPGX (ORCPT ); Thu, 26 Apr 2018 11:06:23 -0400 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 83FA22A604C; Thu, 26 Apr 2018 17:06:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Vf-QMZzw2TxY; Thu, 26 Apr 2018 17:06:20 +0200 (CEST) Received: from kaveri (145.233.60.188.dynamic.wline.res.cust.swisscom.ch [188.60.233.145]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 31DA72A604B; Thu, 26 Apr 2018 17:06:19 +0200 (CEST) Received: from daenzer by kaveri with local (Exim 4.91) (envelope-from ) id 1fBiTS-0003W3-Sl; Thu, 26 Apr 2018 17:06:18 +0200 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= To: =?UTF-8?q?Christian=20K=C3=B6nig?= , Roger He Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/ttm: Use GFP_TRANSHUGE_LIGHT for allocating huge pages Date: Thu, 26 Apr 2018 17:06:18 +0200 Message-Id: <20180426150618.13470-2-michel@daenzer.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180426150618.13470-1-michel@daenzer.net> References: <20180426150618.13470-1-michel@daenzer.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michel Dänzer GFP_TRANSHUGE tries very hard to allocate huge pages, which can result in long delays with high memory pressure. I have observed firefox freezing for up to around a minute due to this while restic was taking a full system backup. Since we don't really need huge pages, use GFP_TRANSHUGE_LIGHT | __GFP_NORETRY instead, in order to fail quickly when there are no huge pages available. Set __GFP_KSWAPD_RECLAIM as well, in order for huge pages to be freed up in the background if necessary. With these changes, I'm no longer seeing freezes during a restic backup. Cc: stable@vger.kernel.org Signed-off-by: Michel Dänzer --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 11 ++++++++--- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 2ce91272b111..6794f15461d9 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -914,7 +914,8 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, while (npages >= HPAGE_PMD_NR) { gfp_t huge_flags = gfp_flags; - huge_flags |= GFP_TRANSHUGE; + huge_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | + __GFP_KSWAPD_RECLAIM; huge_flags &= ~__GFP_MOVABLE; huge_flags &= ~__GFP_COMP; p = alloc_pages(huge_flags, HPAGE_PMD_ORDER); @@ -1033,11 +1034,15 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) GFP_USER | GFP_DMA32, "uc dma", 0); ttm_page_pool_init_locked(&_manager->wc_pool_huge, - GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), + (GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | + __GFP_KSWAPD_RECLAIM) & + ~(__GFP_MOVABLE | __GFP_COMP), "wc huge", order); ttm_page_pool_init_locked(&_manager->uc_pool_huge, - GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) + (GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | + __GFP_KSWAPD_RECLAIM) & + ~(__GFP_MOVABLE | __GFP_COMP) , "uc huge", order); _manager->options.max_size = max_pages; diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index 291b04213ec5..5a551158c289 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -910,7 +910,8 @@ static gfp_t ttm_dma_pool_gfp_flags(struct ttm_dma_tt *ttm_dma, bool huge) gfp_flags |= __GFP_ZERO; if (huge) { - gfp_flags |= GFP_TRANSHUGE; + gfp_flags |= GFP_TRANSHUGE_LIGHT | __GFP_NORETRY | + __GFP_KSWAPD_RECLAIM; gfp_flags &= ~__GFP_MOVABLE; gfp_flags &= ~__GFP_COMP; } -- 2.17.0