Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1882321lqo; Mon, 13 May 2024 00:48:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaqfNcgYzb2oUpELhH/G4oQZtunR3tN4atoj6L6opaDOADYoymNXAkLCW0CF3yDemqg31HQO78Ghrxy5iqpV1m4TSO9iZmtIMKLrW3uA== X-Google-Smtp-Source: AGHT+IEmYexHr/qjW+YHzcoXLkvpL8HgFfOTRd5Gb9lpU354wj3fkEoL2RklGnhM4Qs7S3C5mltd X-Received: by 2002:a17:906:eb46:b0:a59:a85c:a5c6 with SMTP id a640c23a62f3a-a5a2d585996mr596209966b.22.1715586524733; Mon, 13 May 2024 00:48:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715586524; cv=pass; d=google.com; s=arc-20160816; b=0tn6bYPLS8vs8ESu0qp1zHBu6tNS+yTxSkvmAyKDb5UgDXr+xTK33qR2TIFNu8QJbc alP+XBYvv7agCFZy0uJwIACWzQaSc6Z2MIzFdt+2DgqcLqLfykRW8yvXwmw50jqmGfz7 u+ITzT5KNO8pa10U+vU/ZUyYtHWpMYV4Lt5FQ2fJxjUuJomArOIH8o+yMdRJPGWDZk3a udYViJIZuSpT8qqYwEWxSVjbSkO21EUeJ0sj7MXV6TH1lf2JFfaPxAf8St0Hq15E7fY2 FCxt7ub68ZS+oeeuYmt+p5MGv4DQCW4cyPsz9KDYOnAINFCEgnpnG4qPt8Fd+3x9lDrn It+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=d2aMd7RSjLCt9aorWWhiNJrgbBDqFo4vIbYySyvRoqM=; fh=ORlOz5p8+z9Yznxey/KhrGIzMNKuZ756OgybvXZmd8A=; b=znTPEgggfXEvlL+hL8vFBmOKn3sGtoXqmXx6l19Sgio5hVE9ZPb4BDZR+4n0uTmJ/e C55oRSdov09btzj4ppNeEvzK+MtSzQEpj8FNpjZH3qcX84mMBk72rT7Nb4bh+iS/caVi yBbrrUJwniLLtcvnjH8jCw+FMFIr4T3ppWU9o247jrutiJsn52ao616cybbbPafcEQ7S 2hCPdzPHxDRp1cgNDA2Slcx5yqd9XKBk+siOf5lrzc85uBZ4fcRoeX7yZY4adDgCO0Ms 49wo0HnlLTSsNjm+ZpqmlOfYDaKznLJm58WShO7XfcsVtSOKiuqVqxHb+xcfcgkhNYwt wERg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jKF2Ff0W; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-177281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17be69d8si443125866b.789.2024.05.13.00.48.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jKF2Ff0W; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-177281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 75D971F2135C for ; Mon, 13 May 2024 07:48:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A72CA146A8E; Mon, 13 May 2024 07:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKF2Ff0W" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AADF5146D66 for ; Mon, 13 May 2024 07:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715586488; cv=none; b=cb2wQkThtDFFMoMDQpo9/nKyAGyrw+E0mgJKz7Tz7cBkLgqvHx5PqQ+U8qEQTOWj5C0B9li8C4Bg2TyghFKF0nY32MiNMcu/ZwuXO+SCVDSTR9M5sIvvsL734uR5B8UwOWAlU7iwgaF7Nw5hnyfpb4XjItmFlAbgFlCckEDYmbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715586488; c=relaxed/simple; bh=LVB2t4hgTGzc+6gDjDH8VhApIuASOYTgUThH5iWUziQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EYoE6Cszacf+OtTFL3NbGgI2nWE49ZwvbMKO1wWmDyhiMP+05HfU3IGgsyPgOL4+leNjgZMG/sUglrDhHZkNIgFv/FrOzkOaDXZomWkWt9ZU7N9Ie/GM9x4laMd/LQViKNGl6ZQkk3Mhlq5iG8c8txjuwLUAtELOqPvnoAkj1hs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jKF2Ff0W; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6f467fb2e66so3626615b3a.1 for ; Mon, 13 May 2024 00:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715586487; x=1716191287; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d2aMd7RSjLCt9aorWWhiNJrgbBDqFo4vIbYySyvRoqM=; b=jKF2Ff0WZPWRrdxB2ov0xTz8MUGzvdASzOVjLD6d761pjJGDCxRnUE6xATosuFCXFk OQC2+1bNp+MYnVNg/3ttBa1bG7fIMq5F7cRlMWH/AIhW4+TgtUIHOKBWQFyDCd//xMMp c9uNMxI4uMKfJ1Msu8eUAUeppv1IV0sC+BH7yRHfPYU7rUm0itBYvszJXZ8T3xBJZVNJ 4fBzyznrE8/p08zJxrTuQRWnQ93SaeFvaUINESS7aGYQm/krPfG5hf8wGxiLOKjUbOA7 NgpCMKzWpoug5d59ZqWsjUUkxoa83Q5cIqqKjghWfp3jZ2/MZxmTYkdljaMKhHzQlHfd XXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715586487; x=1716191287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d2aMd7RSjLCt9aorWWhiNJrgbBDqFo4vIbYySyvRoqM=; b=INbFy8hh6guiaoVA6VnZEJ++zdUyaIdQUtsKt3jIqnZaFTX1RWRG5NjVxozyr8jqDv 0i6Bv5PN4RZWCvni7pP9uiI65PDDI+eu3c6nEHX6waHwzsfilugKJwWP/Z6i+vVpviUR oeFzC5rNgU5lQBcw+13B2wCCMp7/MfphJ48AcyrmAjJJkNqBUqpmqGpdZX5sQ9sNlhdj NWq54FQgteFtnV955aF6io9UE5x08GH3aVrWlS+uVqz2XKsvv/1B1DfY+8K82LFzzVwh OISnRCitFZXMiKLibaKGZNnF775Inv5O12hTl4v81ZG193DaWW9miHMcCI4QG8a2hVnm C95g== X-Forwarded-Encrypted: i=1; AJvYcCUZKj75g4DfwT+8m55BQFhSgb0a9oYT/MaMpER58f68qLvaF7Z64knHDkhIMej4n0948X5DtDCC2/58iyNu8PwlLzw4M8YULmgZvxVq X-Gm-Message-State: AOJu0YxVGpb7GyCNgnfsC0eFrTbbczuRj7FpcC8YXelMsezdE+Jpwb78 pr1P/tUX2JJUR2lJy0sZKcs7E/EHLiooH9iCck42E4xKmu4Oxj+q X-Received: by 2002:a05:6a00:2195:b0:6ec:f28b:659f with SMTP id d2e1a72fcca58-6f4e02988b7mr11861591b3a.3.1715586487009; Mon, 13 May 2024 00:48:07 -0700 (PDT) Received: from LancedeMBP.lan.lan ([2403:2c80:6::304b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a66621sm7008967b3a.13.2024.05.13.00.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:48:06 -0700 (PDT) From: Lance Yang To: akpm@linux-foundation.org Cc: willy@infradead.org, sj@kernel.org, baolin.wang@linux.alibaba.com, maskray@google.com, ziy@nvidia.com, ryan.roberts@arm.com, david@redhat.com, 21cnbao@gmail.com, mhocko@suse.com, fengwei.yin@intel.com, zokeefe@google.com, shy828301@gmail.com, xiehuan09@gmail.com, libang.li@antgroup.com, wangkefeng.wang@huawei.com, songmuchun@bytedance.com, peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Lance Yang Subject: [PATCH RESEND v5 3/4] mm/mlock: check for THP missing the mlock in try_to_unmap_one() Date: Mon, 13 May 2024 15:47:11 +0800 Message-Id: <20240513074712.7608-4-ioworker0@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20240513074712.7608-1-ioworker0@gmail.com> References: <20240513074712.7608-1-ioworker0@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The TTU_SPLIT_HUGE_PMD will no longer perform immediately, so we might encounter a PMD-mapped THP missing the mlock in the VM_LOCKED range during the pagewalk. It's likely necessary to mlock this THP to prevent it from being picked up during page reclaim. Suggested-by: Baolin Wang Signed-off-by: Lance Yang --- mm/rmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index 4c4d14325f2e..08a93347f283 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1671,7 +1671,8 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, if (!(flags & TTU_IGNORE_MLOCK) && (vma->vm_flags & VM_LOCKED)) { /* Restore the mlock which got missed */ - if (!folio_test_large(folio)) + if (!folio_test_large(folio) || + (!pvmw.pte && (flags & TTU_SPLIT_HUGE_PMD))) mlock_vma_folio(folio, vma); goto walk_done_err; } -- 2.33.1