From mboxrd@z Thu Jan 1 00:00:00 1970 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 E7DABC433EF for ; Wed, 9 Feb 2022 22:59:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 452EF6B0074; Wed, 9 Feb 2022 17:59:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 401C56B0075; Wed, 9 Feb 2022 17:59:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C9876B0078; Wed, 9 Feb 2022 17:59:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 1E81D6B0074 for ; Wed, 9 Feb 2022 17:59:24 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CA41D951A9 for ; Wed, 9 Feb 2022 22:59:23 +0000 (UTC) X-FDA: 79124759406.14.92AF3D6 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf01.hostedemail.com (Postfix) with ESMTP id B411540003 for ; Wed, 9 Feb 2022 22:59:22 +0000 (UTC) Received: by mail-oi1-f175.google.com with SMTP id q8so4134915oiw.7 for ; Wed, 09 Feb 2022 14:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=uvj18JdALDTyA26ImErFuNGy6B/8vAJVfVxxI7MGaTM=; b=WG/G4fGENpWX/XkeGR6QHmH0cDKSeBMbhz7z2mK9w0WbYRRbQCRYbnXEG7sPMtBEOu uPopYA7OsEiCPUbRQ4MsoO8Zb3Yg/QORv8SB6g4q1LPqRNdmvJSXsT3lqQpk9DU3/qjb SX6Y418c2GNAnZHLTh+3uex7L44FUpBBioEcUp15x3Zd+1We3LZr3FenKLzQsJF9g1r2 ui9YlyiDfa3xZOv1j6+JQ9M+ypoYiUqecjbMRSN6C2YXmiNc8cr6HKKedXHkbYj3bXP5 AtDMrX96q4GYnjeiKI0efYQZkwfix5/mN/bMOoSKBXQrQuaNdZyhLPi7Jbk2eqNTI0jg YS+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=uvj18JdALDTyA26ImErFuNGy6B/8vAJVfVxxI7MGaTM=; b=2PE82qMWCsYiZtHr1SM642l2HhgeeFfyLRLU06CIbpbl4CImQcrIT+Ti9Voek7pfyX CKSzhm8FI0r3kCD223N/ee/73tDz1jIdxXSxE3cUKr+n6ahnqhl7hoUUJpfZmVhnOSjP 6/31FfKyiaUCzo8YmdDwj3s8suPLULuDQ7MmZuK4vKTAaccYltZL5Gf0qABBEZQ9pC+L 23Ya6vHfm3FbeYihJxvMj5468uZuYmDHnxUIV/UANnw+Hl3P2+Ocwq6/XUsY1a1zsL+5 8bp6ZL0j9RQWMNIB8aETXIjM+ZGy3Y1bNp4v0uEWCgrdx3nVk0iPibqhf5zAwY5OZ85W UjRg== X-Gm-Message-State: AOAM530lnrD7Ki9gj+F5XMApRwUJH01BbLpWTElwK4UU9flwd2J/Jm6S 3MtI67F9L3ddL1GP+FxcXPAeTA== X-Google-Smtp-Source: ABdhPJxJeLENcMrkf/ZQi9jdBZuxAD8iKmvJxNmhwu3EHmzGdlRZG6UqgJALyeHjqPem3G5g0ytwFw== X-Received: by 2002:a05:6808:1902:: with SMTP id bf2mr2059138oib.55.1644447562612; Wed, 09 Feb 2022 14:59:22 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id bl6sm7359384oib.38.2022.02.09.14.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 14:59:21 -0800 (PST) Date: Wed, 9 Feb 2022 14:59:19 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Michal Hocko cc: Hugh Dickins , Andrew Morton , Vlastimil Babka , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Alistair Popple , Johannes Weiner , Rik van Riel , Suren Baghdasaryan , Yu Zhao , Greg Thelen , Shakeel Butt , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 00/13] mm/munlock: rework of mlock+munlock page handling In-Reply-To: Message-ID: References: <8e4356d-9622-a7f0-b2c-f116b5f2efea@google.com> <147388c6-eb7-5c58-79a-7a8279c27fd@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="WG/G4fGE"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=hughd@google.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B411540003 X-Stat-Signature: j5ciq344wbqj3d1os6ohr3tm3koyom17 X-HE-Tag: 1644447562-398713 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: On Wed, 9 Feb 2022, Michal Hocko wrote: > On Wed 09-02-22 08:21:17, Hugh Dickins wrote: > > On Wed, 9 Feb 2022, Michal Hocko wrote: > [...] > > > The only thing that is not entirely clear to me at the moment is why you > > > have chosen to ignore already mapped LOCKONFAULT pages. They will > > > eventually get sorted out during the reclaim/migration but this can > > > backfire if too many pages have been pre-faulted before LOCKONFAULT > > > call. Maybe not an interesting case in the first place but I am still > > > wondering why you have chosen that way. > > > > I'm puzzled: what makes you think I'm ignoring already mapped LOCKONFAULT > > pages? I'd consider that a bug. > > I've had the following path in mind > __mm_populate > populate_vma_page_range > if (vma->vm_flags & VM_LOCKONFAULT) > return nr_page > > which means that __get_user_pages is not called at all. This also means > that follow_page_mask is skipped. The page table walk used to mark > already mapped pages as mlocked so unless I miss some other path it > would stay on its original LRU list and only get real mlock protection > when encountered by the reclaim or migration. That is so until 04/13: but then, whenever a page is faulted into a VM_LOCKED area (except when skipping pte-of-compound) it goes through mlock_page(). So it will then lock-on-fault. Ah, but you're worrying about any previously-mapped pages when VM_LOCKONFAULT is established: those ones get done by mlock_pte_range() in 07/13, same as when VM_LOCKED is established - I checked again, VM_LOCKONFAULT is not set without VM_LOCKED. > > > It is the case, isn't it, that a VM_LOCKONFAULT area always has VM_LOCKED > > set too? If I've got that wrong, yes, I'll need to revisit conditions. > > Yes, I did't really mean we would lose the mlock protection. We would > just do the lazy mlock also on pages which are already mapped. This is > certainly not a correctness issue - althoug stats might be off - but it > could polute existing LRUs with mlocked pages rather easily. Even with the lazy mlock in reclaim, I'd still accuse myself of a bug if I've got this wrong. > > As I've said. Either I am still missing something or this might even not > be a big deal in real life. I was mostly curious about the choice to > exclude the page table walk for LOCKONFAULT. It surprised me too: but looking at how FOLL_POPULATE was handled in faultin_page(), it appeared to me to become redundant, once mlocking was counted at fault time (and in mlock_pte_range() - maybe that's the page table walk you're looking for, not excluded but moved). It is a big deal for me: please don't let me fool you, please do continue to worry at it until you're convinced or you convince me. Thanks, Hugh