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=-7.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, 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 87316C433ED for ; Tue, 14 Jul 2020 16:08:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4CB2422515 for ; Tue, 14 Jul 2020 16:08:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="quO5N6og" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CB2422515 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D26846B0006; Tue, 14 Jul 2020 12:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD6A38D0001; Tue, 14 Jul 2020 12:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEB936B0008; Tue, 14 Jul 2020 12:08:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id A5D206B0006 for ; Tue, 14 Jul 2020 12:08:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 51B87180ACF7F for ; Tue, 14 Jul 2020 16:08:46 +0000 (UTC) X-FDA: 77037164652.21.fruit70_2b0f00326ef2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id F19CA180442CD for ; Tue, 14 Jul 2020 16:08:45 +0000 (UTC) X-HE-Tag: fruit70_2b0f00326ef2 X-Filterd-Recvd-Size: 6085 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 16:08:45 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id q198so16072628qka.2 for ; Tue, 14 Jul 2020 09:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fXf8zgvJD8RyvdGVU6SbrLCxfrnGixneNILyC8ZbGYQ=; b=quO5N6ogCCYMCYm0jbm7VGfgMCjMNG3GM9hD87QoYYFvrCvi+38UVqmSgHvpoMIvtp MK4ykcB/BoIm3XFsCMscMRa5eaFT+7xKl2rw3pj0xGgGwuSg2KA+KUQ0dVZgVWXhqKjh TSWDGLrqQ1V0hHYAbPLbQ37d/oBs3FOrP2lo8= 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=fXf8zgvJD8RyvdGVU6SbrLCxfrnGixneNILyC8ZbGYQ=; b=bzeT0dgpKgcmUCesqnzQgkS6GBdO2nGUe/yFhSippJJxS9cv9cLGLCr8iqxWxqftDq cEdueMbK5rgWRSN2u8eXtich3TTPo5COgYLTmqP9W68EGqM0ccjFK29SK9l5txxicZc0 S08O/BLGXd1G/x6CcPZxrYYvLZNd5yLjoovGhfCUov0dUvopvWlwoaXe9PtuwTtWsZ/o sQfAnBm+d1SzLNv9jd8InMtg8Zd6aiOUpwqt+Smzefn6i11e8xXgTTX6tkuZz2nGXA3v 1G65eRN1C3sAPTVrtAHAWfxEzixYRoZIi+eKSbxZSrkFScAyPdOYzrGpAmBnUyFF4HAQ +TrQ== X-Gm-Message-State: AOAM530C/RCZ3iolVFq2FeS8bl9sCazCs4wXQbL6x6ruhjblvBaGE8c9 txcq/krbvPsnons8LDLdTlQUnA== X-Google-Smtp-Source: ABdhPJz9QAcH+YKs1fhtplNEgSvm1zFmMYsJh/XrGm1MUTK4ti2w3rCC8VJsOCnzYlhLv6MJYRwPxw== X-Received: by 2002:a37:a950:: with SMTP id s77mr5236642qke.171.1594742924543; Tue, 14 Jul 2020 09:08:44 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id m4sm25213289qtf.43.2020.07.14.09.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 09:08:43 -0700 (PDT) Date: Tue, 14 Jul 2020 12:08:43 -0400 From: Joel Fernandes To: "Kirill A. Shutemov" Cc: Linus Torvalds , Naresh Kamboju , linux- stable , open list , linux-mm , Arnd Bergmann , Andrew Morton , Roman Gushchin , Michal Hocko , lkft-triage@lists.linaro.org, Chris Down , Michel Lespinasse , Fan Yang , Brian Geffon , Anshuman Khandual , Will Deacon , Catalin Marinas , pugaowei@gmail.com, Jerome Glisse , Greg Kroah-Hartman , Mel Gorman , Hugh Dickins , Al Viro , Tejun Heo , Sasha Levin Subject: Re: WARNING: at mm/mremap.c:211 move_page_tables in i386 Message-ID: <20200714160843.GA1685150@google.com> References: <20200712215041.GA3644504@google.com> <20200714073306.kq4zikkphqje2yzb@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200714073306.kq4zikkphqje2yzb@box> X-Rspamd-Queue-Id: F19CA180442CD X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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, On Tue, Jul 14, 2020 at 10:33:06AM +0300, Kirill A. Shutemov wrote: > On Sun, Jul 12, 2020 at 03:58:06PM -0700, Linus Torvalds wrote: > > Anybody else have any opinions? > > Maybe we just shouldn't allow move_normal_pmd() if ranges overlap? > > Other option: pass 'overlaps' down to move_normal_pmd() and only WARN() if > see establised PMD without overlaps being true. I was thinking we should not call move_page_tables() with overlapping ranges at all, just to keep things simple. I am concerned about other issues such as if you move a range forward, you will end up overwriting part of the source range. Allow me some time to develop a proper patch, I have it on my list. I will try to get to it this week. I think we can also add a patch to detect the overlap as you did and warn in such situation. Thoughts? thanks, - Joel > Untested patch: > > diff --git a/mm/mremap.c b/mm/mremap.c > index 5dd572d57ca9..e33fcee541fe 100644 > --- a/mm/mremap.c > +++ b/mm/mremap.c > @@ -245,6 +245,18 @@ unsigned long move_page_tables(struct vm_area_struct *vma, > unsigned long extent, next, old_end; > struct mmu_notifier_range range; > pmd_t *old_pmd, *new_pmd; > + bool overlaps; > + > + /* > + * shift_arg_pages() can call move_page_tables() on overlapping ranges. > + * In this case we cannot use move_normal_pmd() because destination pmd > + * might be established page table: move_ptes() doesn't free page > + * table. > + */ > + if (old_addr > new_addr) > + overlaps = old_addr - new_addr < len; > + else > + overlaps = new_addr - old_addr < len; > > old_end = old_addr + len; > flush_cache_range(vma, old_addr, old_end); > @@ -282,7 +294,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma, > split_huge_pmd(vma, old_pmd, old_addr); > if (pmd_trans_unstable(old_pmd)) > continue; > - } else if (extent == PMD_SIZE) { > + } else if (!overlaps && extent == PMD_SIZE) { > #ifdef CONFIG_HAVE_MOVE_PMD > /* > * If the extent is PMD-sized, try to speed the move by > -- > Kirill A. Shutemov