Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2343957imm; Thu, 7 Jun 2018 09:05:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJb6bG/Y+pogfabUv0B5R7XsKqAXatJMe6W0CuVCxx7+aKBPLB0Wb7wGiyijuWYauUsRsHq X-Received: by 2002:a65:5c42:: with SMTP id v2-v6mr2099276pgr.224.1528387543394; Thu, 07 Jun 2018 09:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528387543; cv=none; d=google.com; s=arc-20160816; b=TYUrLLGvImjSUr/YWcaBCHjqio1F5tMQroeUpGKiA3aoE/qm18I73AB+KaDG+HzR2K H3p49FzDjmunZj8UPClE3HHdVAw8uMKFu6FnHVfZtZJY4QUQoDLdt/ReGWJgAIL6LnSp RuGpdjZdpQ6tgg1xpYBsO5SgL2qE8Wwtn05MorZhauMlHMVnBCRLdeLwnPo8yj2Je2yz wFhDZ8dbP1aVsuZyqG/bL0d600OXyuN7eQ7SgjarIBUVBxZQJCOJ/dacDYtcv3SHb0zU 8t4DKVX/g5bd00mbIKF4ppspNkjFs5zoIpVrF419ADOkuB9anvmaqpJXfCDH0vrLrZkY J33Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=v7VLXVSfJ3Oz2Xr9pAeSQgO58Sr7eDij93+hJd7UcrI=; b=Z5OMoknyZptjIEPWxgVZMC4bExsd+TcQ1GT8Cq2av6cux/AzOHmSCpd03Cvg1rrHVt bFhRk7FuxXz8ANWFxsDcsc9zW61mc0H7EG2Ht7A2SfaOL7LE2tstgXjKLD120R2zmUWI Nstza9V+JSLstG3LsdYv7hShsd+oIn8cd0JNgvqrQ9fWNK+rXgtz/hzxxkd/ro8ZCu7i UhGITaRvFp0B8+hr8tK8A8rkfFzPEDsfRpqGE1JCiqhm3RtEX3kSap5ere0ykG5dTpJw QyTCtV/KOAz0aE4ro0hgdUYxToIiiLtUOseQXkhs5+bCknK3jmx40JQptuUAe7rofdvn /99Q== 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 a7-v6si14599085pgv.360.2018.06.07.09.05.27; Thu, 07 Jun 2018 09:05:43 -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 S935394AbeFGQD4 (ORCPT + 99 others); Thu, 7 Jun 2018 12:03:56 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39259 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933020AbeFGOJE (ORCPT ); Thu, 7 Jun 2018 10:09:04 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb4-0005dI-9y; Thu, 07 Jun 2018 15:09:02 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb3-0002sx-7r; Thu, 07 Jun 2018 15:09:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Felix Kuehling" , "Christian =?UTF-8?Q?K=C3=B6nig?=" , "Alex Deucher" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 143/410] drm/ttm: Don't add swapped BOs to swap-LRU list In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Felix Kuehling commit fd5002d6a3c602664b07668a24df4ef7a43bf078 upstream. A BO that's already swapped would be added back to the swap-LRU list for example if its validation failed under high memory pressure. This could later lead to swapping it out again and leaking previous swap storage. This commit adds a condition to prevent that from happening. v2: Check page_flags instead of swap_storage Signed-off-by: Felix Kuehling Reviewed-by: Christian König Signed-off-by: Alex Deucher [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/gpu/drm/ttm/ttm_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -175,7 +175,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer list_add_tail(&bo->lru, &man->lru); kref_get(&bo->list_kref); - if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { + if (bo->ttm && !(bo->ttm->page_flags & + (TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) { list_add_tail(&bo->swap, &bo->glob->swap_lru); kref_get(&bo->list_kref); }