From patchwork Thu Jun 16 17:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12884643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD17CCA47A for ; Thu, 16 Jun 2022 17:48:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C9216B0075; Thu, 16 Jun 2022 13:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54FFD6B0078; Thu, 16 Jun 2022 13:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C9266B007B; Thu, 16 Jun 2022 13:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2E3576B0075 for ; Thu, 16 Jun 2022 13:48:54 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 0671D80F97 for ; Thu, 16 Jun 2022 17:48:54 +0000 (UTC) X-FDA: 79584834588.24.D720E5D Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf13.hostedemail.com (Postfix) with ESMTP id 9693320088 for ; Thu, 16 Jun 2022 17:48:53 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id k12-20020a17090a404c00b001eaabc1fe5dso2478470pjg.1 for ; Thu, 16 Jun 2022 10:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IVDYrUdqiRm9UcRbpXweUBj4/hDRVoO4CK1KpBPozys=; b=YoZ1bssMZl0ds5wLwIPKg0IItqCPaKU17iyetjJF+hT+7KvhMVimEkgRt95TZkLAxO FnqS18PmPzsWKkIght4RbuqwygilGASy2GLKqKg6k/vzT6t+DtM4UxAQl5b7P9A3TNNf eNO3UdSwBlFGrUig73CtXZrfbbh+sfQ3yu/6CT/tziWSALK5brivuz9r9Oul1PmCzrfZ vwzv81Kzs6hCvJuSzDap1wEz3A/BmNXbZucyPTub2avd33WiHFdjm29e8KsZtbG6Ob56 R8nESRo3DArWhf+2Xo28r7HWLmRlqKlf75OJ1nRX8ig9JYoj6D/6DI+3HTWP9r+gSf7n AW3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IVDYrUdqiRm9UcRbpXweUBj4/hDRVoO4CK1KpBPozys=; b=1NrcI++N6uamcbjkd0LEKkmUj1BUppkrYwOwI/kOQ0Yw7FyLTeT3LJN5fd25TFnLIT RJVUMFq6ojdenEAFfhvCpomChOWhP886yIb+s4cSVY+L3OOThFg9a6xiD6imXGHJkcjf J4l8vj0BNbviWnkY5lHT0tPJbsCQjl3NvCIxp9+oLehAEKybSEP1Ny2/x7fD8FAviyHK J861KCvDTDKg8t6wDuqkMLHQsf2D2/OygYlGRoqbWX0Ls9shPf2RaY4PRce92c8ycFEc DnfG9BRHdjK3aCsflJ18dTpBdip1urKjj6mlllfGs2JdAnJy3zJszmwq8LNnOR9yPm76 +FuA== X-Gm-Message-State: AJIora/TjAwrqXJHiUD3u5ZrsEQrDH0YUNxvco0p/uX7uzOhhYK6cVsL 0RG3JWZ3QdO6ZGWNHxmvJhU= X-Google-Smtp-Source: AGRyM1vxGK17GWzftPYeur/8Me6GEPOXRVJXvmUbi9GWcVUiu6WhWb2FJDsYzyvI0N7smHaYh/uyEg== X-Received: by 2002:a17:902:c403:b0:167:4a9f:2799 with SMTP id k3-20020a170902c40300b001674a9f2799mr5716030plk.56.1655401732435; Thu, 16 Jun 2022 10:48:52 -0700 (PDT) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id z21-20020a17090a8b9500b001e8520b211bsm1818289pjn.53.2022.06.16.10.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 10:48:51 -0700 (PDT) From: Yang Shi To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, willy@infradead.org, zokeefe@google.com, linmiaohe@huawei.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v5 PATCH 3/7] mm: khugepaged: better comments for anon vma check in hugepage_vma_revalidate Date: Thu, 16 Jun 2022 10:48:36 -0700 Message-Id: <20220616174840.1202070-4-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220616174840.1202070-1-shy828301@gmail.com> References: <20220616174840.1202070-1-shy828301@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=YoZ1bssM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655401733; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IVDYrUdqiRm9UcRbpXweUBj4/hDRVoO4CK1KpBPozys=; b=k6XTIrYfvTrPri++y5uLawXR2ArEHl+753JU6TXU/5j2wqD7GazW4E0pZNm8Xd4qEi9Xdt B7xC0L2+wPXMGARWj5XHR62Wi8m0HHWqF74mM2IsJtfGpChecDlWStPoPA1smEXRg8l+k6 TvL9mYD3bV7Xr+Qk1SxNue7tOtcnWUM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655401733; a=rsa-sha256; cv=none; b=wa5n9zoaHbJZj4KkBlouFVjpDTCcKnXzUHMOIngKWHi/Ok3oosYSw3iC3UXBXwoxFdLBw8 EDwmMSu5iBsH66AGKH2N3WKmOJZ4EO0ivwqyFrRJDuFPXmv2wcA3VSQy4T0B/q/Nd8O99F HdZKmNEHVbcOFackOO5huL74AM612tk= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9693320088 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=YoZ1bssM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Stat-Signature: b5hbuzm9ctkr91grd5xkzwhufwr9edf7 X-HE-Tag: 1655401733-606132 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: The hugepage_vma_revalidate() needs to check if the vma is still anonymous vma or not since the address may be unmapped then remapped to file before khugepaged reaquired the mmap_lock. The old comment is not quite helpful, elaborate this with better comment. Reviewed-by: Zach O'Keefe Signed-off-by: Yang Shi --- mm/khugepaged.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index db0b334a7d1f..5baa394e34c8 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -960,7 +960,13 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address, return SCAN_ADDRESS_RANGE; if (!hugepage_vma_check(vma, vma->vm_flags)) return SCAN_VMA_CHECK; - /* Anon VMA expected */ + /* + * Anon VMA expected, the address may be unmapped then + * remapped to file after khugepaged reaquired the mmap_lock. + * + * hugepage_vma_check may return true for qualified file + * vmas. + */ if (!vma->anon_vma || !vma_is_anonymous(vma)) return SCAN_VMA_CHECK; return 0;