Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp835209ybv; Thu, 13 Feb 2020 10:21:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyolAxPA2sBSSz/bTAnq7qicSxov+tGo5YeQakdJgc6Y8wz5wZI9rCjIR+2lwoaac9cagE0 X-Received: by 2002:a05:6808:10b:: with SMTP id b11mr3942471oie.110.1581618098350; Thu, 13 Feb 2020 10:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581618098; cv=none; d=google.com; s=arc-20160816; b=HPHCP6fBXNILyNuGdJXqjc6aYmMQ36/I56ai3jLwsWEcESeQVNEa/0wF4fmAtKf1FK kio+FAqiflUvaj4N8J2nh+wgsoPiWZtQRsP+AYUma3I4f5xFnh14xjacAojWpWoaOt6V 1FtIj4srZAUGbmyxClOCvzX5Q7pMOdtdnwmXOTeT7LAnT9t+JTxNPAZ3IPIZ9/D0A2ht JdQFbkit+piOxCASZp7il2o8nvrORrswn/1rpcUCiVI2R+4HUZ1JV3AaRATU6O5t1Vhi OkrgA0PmWF4tDBY1iCuXAvCCFn/gHkftfpUmPlarRt1cp5ENsoTe5/+4lakqphl4hp9U DF1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ckYAtFkLGTpqFasss2Yh3sgNnvC6X5fXw2I1Fp2BCnI=; b=FGRb3fvVPBqeQm2dSxZlgtgOyvQlrMjH/os97By8Vog6XR3EL7/kDsc903FBofmmwB Qm43480tp7tdo45rxTXYlva9brzARNBjP/KutYs3BJ2uyJdLm+6Ha1iIV4nxRa3tivcW 7Z2BukbyCeebX01VNv39ayCJeQMLb50vR0BR5uqPuuoLtn+4ThKmx2kmhso3+WYmKJR9 VQ7Mrl4UDP56KDrQbjdVxzsYzMEFxrnaQeinnJ0AZ2uQJy3yf22Jv7rvL1fG6In2D+Qk XKRdD5K8rfoR36vJPr+J4XNhF89BssA9Vu7sRKFT6sixmKspwPKzPV+itCgOhAlSjt5T Sw9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dcS6pegO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 22si1441469oin.34.2020.02.13.10.21.25; Thu, 13 Feb 2020 10:21:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dcS6pegO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727804AbgBMSVN (ORCPT + 99 others); Thu, 13 Feb 2020 13:21:13 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34706 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgBMSVN (ORCPT ); Thu, 13 Feb 2020 13:21:13 -0500 Received: by mail-ed1-f66.google.com with SMTP id r18so8021792edl.1 for ; Thu, 13 Feb 2020 10:21:11 -0800 (PST) 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=ckYAtFkLGTpqFasss2Yh3sgNnvC6X5fXw2I1Fp2BCnI=; b=dcS6pegO12bP6j8/IxZRcJacM50FbD1iRPyqN51QsgWQuddjlR5/CEHWNuIeE9aA3J m7T0l7tq2/Gcod87ssIr+J94iXOhbqETJnhWbz8UtLia+BEPXix4UP2NHFcQrNy0NNoO I9LF6zTMEL2mdpfCuweuZ08YKBckzPkf4JAFtJlnnAIDYYqB6touDFQccxfDXWXmVo8q RYejfAEVD1DrZcyUxTqTcmucp6CwA+iVZuOpyRGNDZL9MWbPi47AtWH2/Il6ez6JQNv3 u3cMYgodLRvwzyGKKU17fkEX23SDPg/uYhyBUuk3wITZPNplSPlzZU3cf8y8PHJGgCvn 0iDw== 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=ckYAtFkLGTpqFasss2Yh3sgNnvC6X5fXw2I1Fp2BCnI=; b=XLN7Zvg/brLcXIfN1vIqNatow1JwDPt7yFdXLwfdyN8tZu4bEGPZbQGmyxSVZxP3pz u/3gBb2w4bEpf6CkYqzg9Z4iMmRx7GvJheY5IrEFIzy4KshhWf/hLkczHU8d72PSL1s0 PmZSvedmwNT2BuQzmO0mIYE5Khnm+VwW97DsNOZvpD3L8jsEjXsZ7yNZGhMgk1VEtb8E CnL8NPWOwugb0i4oUjZDa5xsM39aT25h9VCPPm/fPF6F5v0GBs94pLXRmtOEv75WvKnA OVORsHejHgqV3FpQmoc7OThMMWpqlK0MT/whqFQFfBtlfYJQFupkBtFH1D5IpljKjAwC I7Rg== X-Gm-Message-State: APjAAAUgMj5/Ru0ij2ZC499MAIg7JkDe6501tSIeTIYtew4dxOUndqlJ Q8WRxymwFPTDYTcVOwSwpNBvwf7beyxG7/EgN1rfoA== X-Received: by 2002:a17:906:4e01:: with SMTP id z1mr17455077eju.46.1581618070828; Thu, 13 Feb 2020 10:21:10 -0800 (PST) MIME-Version: 1.0 References: <20200207201856.46070-1-bgeffon@google.com> <20200210104520.cfs2oytkrf5ihd3m@box> <20200213120813.myanzyjmpyzixghf@box> In-Reply-To: <20200213120813.myanzyjmpyzixghf@box> From: Brian Geffon Date: Thu, 13 Feb 2020 10:20:44 -0800 Message-ID: Subject: Re: [PATCH v4] mm: Add MREMAP_DONTUNMAP to mremap(). To: "Kirill A. Shutemov" 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks again for taking the time to review. Brian