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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74348C4741C for ; Fri, 14 Feb 2020 00:36:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 36226218AC for ; Fri, 14 Feb 2020 00:36:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="PacGcFWD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36226218AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B96F86B05C5; Thu, 13 Feb 2020 19:36:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B482E6B05C7; Thu, 13 Feb 2020 19:36:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A36D16B05C8; Thu, 13 Feb 2020 19:36:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 88EE96B05C5 for ; Thu, 13 Feb 2020 19:36:21 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 36C348245571 for ; Fri, 14 Feb 2020 00:36:21 +0000 (UTC) X-FDA: 76486866162.07.lamp15_547966028c625 X-HE-Tag: lamp15_547966028c625 X-Filterd-Recvd-Size: 5561 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Feb 2020 00:36:20 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id b15so5588800lfc.4 for ; Thu, 13 Feb 2020 16:36:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4f0EZeoJlExzljE8pJVUxkTCYd/feIyLQps13jN8CxI=; b=PacGcFWD/+hjRVHJiK+ORMA3HMJLTlsaB+Wjr9TLvq+iI0kdJnr0AbgEl5LQCXI/dw u9AoIP+FTxfxUXlA9Ps6lORc63DbyQgtlHqzF8v7joJKPBftimDS51TTAwiC6vIznm/0 oj1OBSd7sy4hEj+laIQEi6a29v5EbGZeacU7LrVOLyKscRyh8yKZarFWURNE/QpdxCNr nS6TAzXb5s9c4qXfgbfwka7AcihAZNSnsk4769Lij4sI/EPBL0iLtHUaT9LALPJXTIpS YBaGeA5YE3FxbqV/Yh7UmizHXUqeQcRE4l7+8MuaK+AeWHDHey6vx6GeeOE1ZuIPluZ6 SDIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4f0EZeoJlExzljE8pJVUxkTCYd/feIyLQps13jN8CxI=; b=b5rEjExJg7Nmr/0fcdGN3TP3JQbxF9w1gyQZMv+E+lK3WQIS4gu9dyjXPi+W7wdm1T mFG60VPce8gebdqHFwL0tIKKuta1wTtud/D//8V5Tz9eBTZ6gwuNiXWw+vqDPsB04b3y HoWNeRJjprRTTsTGy8U5Iw/NXF2e523EYBGe0/jmV+Shy7elu2T4JK3b6ReiIRFZmNuX EWIOZG1mzRviEyJTUZaFDGBiGTk99nMOijOvf8FFIsqCfUFvUXDQKQldaqDFNLHnMoky Q3Xg6a2i4Lfwzl1ALuPAishmFWPEMolENQPXkwqw2x8HI4APobzDejacSo8iiw3Jyrr4 y5jg== X-Gm-Message-State: APjAAAUgmgQTlxqW1FUOgSvMkopRvrn0RTdPJiiPHFxIyVZ1qQJu/Se8 +ENpZJkQXrT+FTN3l+lHNA7oZA== X-Google-Smtp-Source: APXvYqyX50RxYmxQWDCQJ4bRjVQ1dfugN3SgCgtgCIto9MmZHtlmWbmJtslnfFe7WjbYmJjlQeJHhQ== X-Received: by 2002:ac2:4833:: with SMTP id 19mr261332lft.211.1581640578725; Thu, 13 Feb 2020 16:36:18 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y2sm2437542ljm.28.2020.02.13.16.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 16:36:17 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 1512C100F2C; Fri, 14 Feb 2020 03:36:40 +0300 (+03) Date: Fri, 14 Feb 2020 03:36:40 +0300 From: "Kirill A. Shutemov" To: Brian Geffon Cc: Andrew Morton , "Michael S . Tsirkin" , Arnd Bergmann , LKML , linux-mm , Linux API , Andy Lutomirski , Will Deacon , Andrea Arcangeli , Sonny Rao , Minchan Kim , Joel Fernandes , Yu Zhao , Jesse Barnes , Nathan Chancellor , Florian Weimer Subject: Re: [PATCH v4] mm: Add MREMAP_DONTUNMAP to mremap(). Message-ID: <20200214003640.yphbnjw7omsx2rje@box> References: <20200207201856.46070-1-bgeffon@google.com> <20200210104520.cfs2oytkrf5ihd3m@box> <20200213120813.myanzyjmpyzixghf@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Feb 13, 2020 at 10:20:44AM -0800, Brian Geffon wrote: > Hi Kirill, > > > But if you do the operation for the VM_LOCKED vma, you'll have two locked > > VMA's now, right? Where do you account the old locked vma you left behind? > > You bring up a good point. In a previous iteration of my patch I had > it clearing the locked flags on the old VMA as technically the locked > pages had migrated. I talked myself out of that but the more I think > about it we should probably do that. Something along the lines of: > > + if (vm_flags & VM_LOCKED) { > + /* Locked pages would have migrated to the new VMA */ > + vma->vm_flags &= VM_LOCKED_CLEAR_MASK; > + if (new_len > old_len) > + mm->locked_vm += (new_len - old_len) >> PAGE_SHIFT; > + } > > I feel that this is correct. The only other possible option would be > to clear only the VM_LOCKED flag on the old vma leaving VM_LOCKONFAULT > to handle the MCL_ONFAULT mlocked situation, thoughts? Regardless I'll > have to mail a new patch because that part where I'm incrementing the > mm->locked_vm lost the check on VM_LOCKED during patch versions. Note, that we account mlock limit on per-VMA basis, not per page. Even for VM_LOCKONFAULT. > Thanks again for taking the time to review. I believe the right approach is to strip VM_LOCKED[ONFAULT] from the vma you left behind. Or the new vma. It is a policy decision. JFYI, we do not inherit VM_LOCKED on fork(), so it's common practice to strip VM_LOCKED on vma duplication. Other option is to leave VM_LOCKED on both VMAs and fail the operation if we are over the limit. But we need to have a good reason to take this path. It makes the interface less flexible. -- Kirill A. Shutemov