Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4906570pxj; Tue, 25 May 2021 20:49:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdq1H3mBAScIfyhlo83Sb61yCoYl4+SkJb6z8pcfC0qKREyYjySBXGXvlXDoc8OjLfVgli X-Received: by 2002:aa7:df11:: with SMTP id c17mr35413711edy.317.1622000951917; Tue, 25 May 2021 20:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622000951; cv=none; d=google.com; s=arc-20160816; b=pPQO2RxK0zYyJJ2HzUl58r1ZoijgNw82l+EnCdR2X95A8oEO/horeZnQZrBdh6olFB HeI2fWvbUgHEGYgvY8LAJs3ljOnns3+xDkEcMtW+QCkt/DoOeAZztq7uYuiGZIjYVPfT hejxyajyer9YDavHiQJaeDBsVHjTW8S57CnBJNhj9YdMhyrPhClnT5M0gET5bhAPxZva R5EH2tfmk+3DqcVLNrMjI9LzJZRv7ERddUZr/wr6U06IEk4pv5bBOTXVfaPs0HOsTG5r Ss8+3WCfnCjBTMby6G0Zf0kT+kkmgwcZeeKzxbNdftnNoFzINP66Y/WnghO1pSPNnEJt 5bnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3bWAgXGiiTzRVKYdfnPTxYrHckcttw3uRegUUnWbckY=; b=BuhoaB7dUMLBg9kL8Iig1GFtemknYfBUsbPYe19jpbK8uvldPxByeYR0lcXzxLyPg+ spddr2+0KSeNFmmkDjGRd6RzNiCcp9PxvYk8yKVWNucVoA139jTm95HFiijhnr3AyVaQ TYunw5OnSVqHXbKiJFMsk4fPBTqX9LHtddCVsUTuMu/IYD81CxJWe/4s6jBFttjrsGqL s+jbaE1SS9LnXlb2RaFZhpnQ2uxvqWkJjYKVtthSb5TQpb7JBl1tKiaf/wYpLoC9kP1v zpVdTEGivbNpq9M8f1bIvWKHn92aJTR3QOo+qqtKn9t/hrTc2P+bcrChilj22K7E+II4 cABw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hhrAWAHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si18379682edy.138.2021.05.25.20.48.47; Tue, 25 May 2021 20:49:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hhrAWAHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbhEYXrP (ORCPT + 99 others); Tue, 25 May 2021 19:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbhEYXrN (ORCPT ); Tue, 25 May 2021 19:47:13 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAD41C061574 for ; Tue, 25 May 2021 16:45:41 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id q3so18543070lfu.2 for ; Tue, 25 May 2021 16:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3bWAgXGiiTzRVKYdfnPTxYrHckcttw3uRegUUnWbckY=; b=hhrAWAHsfs4V6Q1rRk+5RzotFe5WWhSfBpNqaVfrq48cm1yZ4mCi/3DHK5lHSGhFsd SmJ1xpnVoC7GwKmpH3GoRruIKeU8Ih6iy6Ws79VyE23+Fo9+g4JbUuKztOnJQ/A75X32 F6tDH6wZDjxQVpUNs2UF0fySZ6sghA7NntIauYgD3MF2VdG4v6OLxVduYDUv5zVgV76d JmwjeX0l2NgUtx/F5ZxGtsUf5xupPKtD5PS/OAlZL4HfxZcTuGUESs0ONaygDVe19cwv FQzPzjRzsZB6Fnrt5Ecm93WJVhOzxD/x/n3M9I7hGisNhSKHzTk/Tm0AJmUjDadrhVhA Z3jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3bWAgXGiiTzRVKYdfnPTxYrHckcttw3uRegUUnWbckY=; b=Kth1GcSqyNTOgAO3sbgph0vUJ8h/WLi6a0gWyVlwU62FLXdI+BfscQ4kFYkgIlU/ch 6k7ooQzr2clgB1OZ3hyM+XavQPS5g+t8vdMV0BSCAmzh6dyEyW4yk79fSyd1b/CheR8j 1ihrDV1vIdOf76LrymyHjsZ5+tmDgHrWBty5QgH0h/RaqeD/mt/5pCXG8taFa692sQ9x vibB1PmTKysptrnyEyPZp0pOB7Qq8CFCFAC8ohkEKuSCTrVDpibGyUHWcl7IJ/UqaPo2 MIN9j4G7iu9Ydcp9knAvGWO+8A3PXv6cTpvytsSfp6B1R4WfhwlC3Ua8pjcmpywHLArs riWg== X-Gm-Message-State: AOAM531WmswJnp16mXrVLSqIDmrNTgOuGpMf76KeajqCmk0bL8v1XA/E 8cUIU8sl1jJaVUPbg9PFl1wC6hLzej9ELxVRzcth8A== X-Received: by 2002:a05:6512:3da3:: with SMTP id k35mr69007lfv.347.1621986339891; Tue, 25 May 2021 16:45:39 -0700 (PDT) MIME-Version: 1.0 References: <20210524132725.12697-1-apopple@nvidia.com> <20210524132725.12697-4-apopple@nvidia.com> <20210525183710.fa2m2sbfixnhz7g5@revolver> In-Reply-To: <20210525183710.fa2m2sbfixnhz7g5@revolver> From: Shakeel Butt Date: Tue, 25 May 2021 16:45:28 -0700 Message-ID: Subject: Re: [PATCH v9 03/10] mm/rmap: Split try_to_munlock from try_to_unmap To: Liam Howlett Cc: Alistair Popple , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "nouveau@lists.freedesktop.org" , "bskeggs@redhat.com" , "rcampbell@nvidia.com" , "linux-doc@vger.kernel.org" , "jhubbard@nvidia.com" , "bsingharora@gmail.com" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "hch@infradead.org" , "jglisse@redhat.com" , "willy@infradead.org" , "jgg@nvidia.com" , "peterx@redhat.com" , "hughd@google.com" , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 11:40 AM Liam Howlett wrote: > [...] > > > > +/* > > + * Walks the vma's mapping a page and mlocks the page if any locked vma's are > > + * found. Once one is found the page is locked and the scan can be terminated. > > + */ > > Can you please add that this requires the mmap_sem() lock to the > comments? > Why does this require mmap_sem() lock? Also mmap_sem() lock of which mm_struct? > > +static bool page_mlock_one(struct page *page, struct vm_area_struct *vma, > > + unsigned long address, void *unused) > > +{ > > + struct page_vma_mapped_walk pvmw = { > > + .page = page, > > + .vma = vma, > > + .address = address, > > + }; > > + > > + /* An un-locked vma doesn't have any pages to lock, continue the scan */ > > + if (!(vma->vm_flags & VM_LOCKED)) > > + return true; > > + > > + while (page_vma_mapped_walk(&pvmw)) { > > + /* PTE-mapped THP are never mlocked */ > > + if (!PageTransCompound(page)) > > + mlock_vma_page(page); > > + page_vma_mapped_walk_done(&pvmw); > > + > > + /* > > + * no need to continue scanning other vma's if the page has > > + * been locked. > > + */ > > + return false; > > + } > > + > > + return true; > > +}