From patchwork Tue Oct 16 17:43:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuo-Hsin Yang X-Patchwork-Id: 10643939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E10C13AD for ; Tue, 16 Oct 2018 17:44:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AADD2A52D for ; Tue, 16 Oct 2018 17:44:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1D12A583; Tue, 16 Oct 2018 17:44:24 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CB5D2A52D for ; Tue, 16 Oct 2018 17:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 629066B000C; Tue, 16 Oct 2018 13:44:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D4A36B000D; Tue, 16 Oct 2018 13:44:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EAF56B000E; Tue, 16 Oct 2018 13:44:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id D39546B000C for ; Tue, 16 Oct 2018 13:44:21 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id r24-v6so6437908ljr.18 for ; Tue, 16 Oct 2018 10:44:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bzoh24FV/7+GlpJwWqjLaXQi/cwzbPAc9pGvjk3V9fU=; b=Qms+78d1vkKjsiLu7hnfMTSIV7MPT19kOEY5zRrz/LM2wT9J2tF7Ia36vj5y/76hrl 7XvKxNAWyadds7tjbqwuAWOgzNuL93/WqQwFEzpe5lBRWachGrShn/A6nyYZk0EGqL0R UtrrOQVlHo059ImeNf3eRpwpEeyPbFDGpOrqw0tkVpnAduEMWxjBQGNQ6rqPkoQ/S0AV ZiiAQgxTnSk5QtZlObBAih/Ptzonx3x9xAm8ojmZp06ZY+BDIvJaTDpF8AAyRmAIfeXR t0DJoy8YD8+oKc/tfgDqfJWkAm7uep05WJnPV0+U3RvRX2/XIJ6MgIw4fjg56xdNXgd+ o7dQ== X-Gm-Message-State: ABuFfogBClrVGwz8maXnIMhGsm9Nz5i0g5ssSpoPK689CbdotlzkYbMu LebnBVGSLw+gulfXtRZUUx4jVbxU8dV30EKc9p1+PlgtMM93hCDet6IlheLO3RIPrLHFSjfyHqc 9MrGSluQ/pRx977+BMqKRuuqFzrp6AZmHcr9nRcR/Fk/T0AvsZ0flIUnIeuAqu4HPIhe0byj7QJ 3XvQISz4j9ZTUlDvlK9x/hju63MlhutJ/nUdvjTNFFsaj9pQ28n9liTv/BF+hnzaFeHnAbTDxGn hCHYiiigK6RnUXEp8cFnhQwh8n2lA2SAx57WYSXez/m6h+87SmT0t0uis4Z3E/y4N2D9FFiAyaT bWpzTfdzoXsxZP+4IxbGkmvZ+SP35JhrUH6XgXeyrmNqW89wALRwhuLhV+9r+pLBgBVY/oFtMuf v X-Received: by 2002:a19:2381:: with SMTP id j123-v6mr13771817lfj.137.1539711861238; Tue, 16 Oct 2018 10:44:21 -0700 (PDT) X-Received: by 2002:a19:2381:: with SMTP id j123-v6mr13771770lfj.137.1539711860120; Tue, 16 Oct 2018 10:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539711860; cv=none; d=google.com; s=arc-20160816; b=iZWCPDWNlKKglGKzPb/bMFO42ojDEGsxi7Ws/HA+bgeVEBRV5h0JI2U+1kO4a/PqMc eT+d51ViUARGGlxoVZvqWVFjYEVmVf5vafJyjpgP4RcAGgJpKlnvrbcbemJhlPzgLzJk 2dliiyIgQlhlqWQWpRK2uWym6exq3T0osuu6o2Q9NkH8a/qKVz6P2IM7YjFhp1/vPYtf tTiCtn8dRpZ/h5eAvBpphy+CE4SVtQaCxw0C4q01CxSxEQdnirC8W1LGfgyBdpDL9tA3 bvPUK4if1JXMqioTHnSnUs8QSDYRoW/z4H7pw0u/s3w47NUGs5d8JyzijVYW8Tv/hoTV LMGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bzoh24FV/7+GlpJwWqjLaXQi/cwzbPAc9pGvjk3V9fU=; b=IOfBrPh2X2z2Sj5czG3sqJUjD3AoTlRaAS+kOa2aDhkxWx6F7RaJ6RMba3dVSLaMtT VGyLnOHkfFZ8BJOsuYDi4dHjfD/2oWIG//c5BlLJxQNboHei+hHyKHwjAZmiyPt7IBgW 8S6RDgJLbZkDhsjUbKuaqDqtXR1NrwAmaToIQPftSUatW5Oh0qQJDbJjtmZf+e45+bo4 M2e1qUMv+GnXZAj7Zz/MHE4ODxByTkZRrtGHVXhCBMdo6+oODieKV8xLjw3JAu/H5/jc 8QNAvmtkNl2W8qF1lBBCjBJ7Uu5fpcoYdWR7ColfDd/QPrbTO/djYcCZ4hxZYtE4qzmS W8dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VZZhVILC; spf=pass (google.com: domain of vovoy@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=vovoy@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z4-v6sor3890102lfh.21.2018.10.16.10.44.19 for (Google Transport Security); Tue, 16 Oct 2018 10:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of vovoy@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VZZhVILC; spf=pass (google.com: domain of vovoy@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=vovoy@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bzoh24FV/7+GlpJwWqjLaXQi/cwzbPAc9pGvjk3V9fU=; b=VZZhVILCqYnAIQ0Py1aB7+7AmPOkaeE42RVE8Jhj5JjdVWhdRtXT5WK3yofvwHmQVn PGP0OpMO7hf88Xvqbfs4AHKY8iJ2C67Wy3FUjpwdP8boe7g6qsahf16u9vpsP4Wzskb2 eD+ckhpDdC0AbactZRmfpNBMf2wOQArMz1fbo= X-Google-Smtp-Source: ACcGV62NYrZwT28IR8MFmwZZbGFLRCdcvOqrPlbCNvCo/CrBJwnz8ZmnbPe9xxOhhusMsEOHtDlhMQ== X-Received: by 2002:a19:8fce:: with SMTP id s75mr1747685lfk.151.1539711859597; Tue, 16 Oct 2018 10:44:19 -0700 (PDT) Received: from vovoy-z840.tpe.corp.google.com ([2401:fa00:1:b:d89e:cfa6:3c8:e61b]) by smtp.gmail.com with ESMTPSA id r4-v6sm3358752ljg.12.2018.10.16.10.44.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 10:44:19 -0700 (PDT) From: Kuo-Hsin Yang To: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Cc: mhocko@suse.com, akpm@linux-foundation.org, chris@chris-wilson.co.uk, peterz@infradead.org, dave.hansen@intel.com, corbet@lwn.net, hughd@google.com, joonas.lahtinen@linux.intel.com, marcheu@chromium.org, hoegsberg@chromium.org, Kuo-Hsin Yang Subject: [PATCH 2/2] drm/i915: Mark pinned shmemfs pages as unevictable Date: Wed, 17 Oct 2018 01:43:00 +0800 Message-Id: <20181016174300.197906-3-vovoy@chromium.org> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog In-Reply-To: <20181016174300.197906-1-vovoy@chromium.org> References: <20181016174300.197906-1-vovoy@chromium.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The i915 driver use shmemfs to allocate backing storage for gem objects. These shmemfs pages can be pinned (increased ref count) by shmem_read_mapping_page_gfp(). When a lot of pages are pinned, vmscan wastes a lot of time scanning these pinned pages. Mark these pinned pages as unevictable to speed up vmscan. Signed-off-by: Kuo-Hsin Yang --- drivers/gpu/drm/i915/i915_gem.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index fcc73a6ab503..e0ff5b736128 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2390,6 +2390,7 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, { struct sgt_iter sgt_iter; struct page *page; + struct address_space *mapping; __i915_gem_object_release_shmem(obj, pages, true); @@ -2409,6 +2410,10 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, } obj->mm.dirty = false; + mapping = file_inode(obj->base.filp)->i_mapping; + mapping_clear_unevictable(mapping); + shmem_unlock_mapping(mapping); + sg_free_table(pages); kfree(pages); } @@ -2551,6 +2556,7 @@ static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) * Fail silently without starting the shrinker */ mapping = obj->base.filp->f_mapping; + mapping_set_unevictable(mapping); noreclaim = mapping_gfp_constraint(mapping, ~__GFP_RECLAIM); noreclaim |= __GFP_NORETRY | __GFP_NOWARN; @@ -2664,6 +2670,8 @@ static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) err_pages: for_each_sgt_page(page, sgt_iter, st) put_page(page); + mapping_clear_unevictable(mapping); + shmem_unlock_mapping(mapping); sg_free_table(st); kfree(st);