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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 2FFB0C2BA83 for ; Thu, 13 Feb 2020 18:21:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB0D1206CC for ; Thu, 13 Feb 2020 18:21:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dcS6pegO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB0D1206CC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 891C66B059D; Thu, 13 Feb 2020 13:21:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 843946B059F; Thu, 13 Feb 2020 13:21:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 730236B05A0; Thu, 13 Feb 2020 13:21:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 58B5C6B059D for ; Thu, 13 Feb 2020 13:21:13 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ED7F0824556B for ; Thu, 13 Feb 2020 18:21:12 +0000 (UTC) X-FDA: 76485920784.03.doll56_a90a611d2663 X-HE-Tag: doll56_a90a611d2663 X-Filterd-Recvd-Size: 4350 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Feb 2020 18:21:12 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id f8so8015515edv.2 for ; Thu, 13 Feb 2020 10:21:12 -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=EUOpggxSX/72iCBWkPl2JSfQQiQ2Ljc+QmPzRVAMRIn30bUt2xuBcfbuAEu/pGEWgl vHzp6lGPS53Gh9nr7rsgYRzUyfA3+WmpWCvPmrHjLk5BTIIeSAoKIh+SIh6cz9NkXt/q 5mAA81U2mwRKnC1TSWRZGIqlROrz4VQbt8tCbzf8AnHFVj9Dfd5IiSVr+9sTxluLO11a XpiRE+37bm4fl/shN76TBpebx8pnzSRn4NKOASZjWdc+N01IUEwjaIjedzL1f0zFBE2c EcGtEUoPw4/IO8J6fIQ4bq4fJFsHWdVqCDh9uy8VaYgi1zTHRD4ixdMAhBBug+M+pyZW MLZA== X-Gm-Message-State: APjAAAX7M0aTw6LBZSI5xQYqfklK99XQIu3FYJZIi0JX3s/LuCPKHKJr YuuLWMX5Ae/zf2dD1o3iE8JsBfRle3KhpVU+zUSI6A== X-Google-Smtp-Source: APXvYqwiJPQ8Fg+Dw3qWjh34zdXDeJrcERoGTVCIyZvCpVoBcfFB4U15IkYT3Sgub2qcfUBd9eIRuKLQ1/iNvIecqKg= 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" 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: 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