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=-4.0 required=3.0 tests=BAYES_00,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 A217CC433E0 for ; Wed, 15 Jul 2020 20:55:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E8DD2065D for ; Wed, 15 Jul 2020 20:55:06 +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="VB27AG9i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E8DD2065D 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 0B5CD6B0005; Wed, 15 Jul 2020 16:55:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08CB08D0002; Wed, 15 Jul 2020 16:55:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE40E6B0007; Wed, 15 Jul 2020 16:55:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id D63366B0005 for ; Wed, 15 Jul 2020 16:55:05 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5CD2A180AD801 for ; Wed, 15 Jul 2020 20:55:05 +0000 (UTC) X-FDA: 77041514970.27.pear71_4f0cf1726efc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 2F7D33D669 for ; Wed, 15 Jul 2020 20:55:05 +0000 (UTC) X-HE-Tag: pear71_4f0cf1726efc X-Filterd-Recvd-Size: 4792 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 20:55:04 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id k17so1869489lfg.3 for ; Wed, 15 Jul 2020 13:55:04 -0700 (PDT) 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=DLG1tBaoE9BO9pWX659OlAVtEZXhuuumMlAWDILOJGk=; b=VB27AG9iwRhJsDz2tFcRHmAng2Z9TEKwor91BN8i3YJAVCn9pl6GBy3XEL0ETGJnXD 9HvJ5hhMyeWjQtJPdGiUWUYGDIhYBzah09uIop996c+tK2eEoYHruwKK6812KPn9KsLL nRm0SvB4CM/c1kCu7/JSsZzNUpiVWJA25wgMg6ZKdLP735erIwDcYAymz3I576S5u9Qb /88OhtDpFmmJq3+LnxeNh8psQ3cT5btBh1OnASrtwpf3v3prqpqLBvBEP9q2ywfYBfVg sijubuLNRhfIOX0SYcjrCusLLPqAmqtu4xROWHUIHJPA0oZbL5Ddu3mgYShhtlb392hs q+aw== 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=DLG1tBaoE9BO9pWX659OlAVtEZXhuuumMlAWDILOJGk=; b=Y7uGqY5sII5sFuOwbv6hM3QkVMreOqpX21iVE+KYZl3k26/VS81gSRCEwZXnXCts9W lehT9hByZu5ITCShbSWJlwg2X2+e3/E3A+Dv6Wco+gGGdp64450RMwcxvlt4FOX8i8wx a7D964HED1FF9ToJoa7Ir8KncJMN7RkISh4w72eLOA++fOPBLDKE438sZ/Q6o/zJOtqt AFKfENB154lJB++UmbQkub3dRn0anEqya2LgmfCuM4Ja2DkvnGn7Of7MWyfC3Jyilduj X5tsqmricD1EM0/oeDk1BW5uLo0uVKK4EFNRPmh6ZuL7W4VOqP4zf/xhTOmzoNq6g/r4 U7VA== X-Gm-Message-State: AOAM532rvOjkqoacZeyY9w1FRFzWR41sGzLAlqA57hatqmyTjfqOtQW2 VZhMwRyTj5IGX84LfXvq6CdrKQ== X-Google-Smtp-Source: ABdhPJzWhykc/WCUeRfE6WSX7VQjb88uxneZFyAg1LMmhA3ll7gKJPNukxznwmI9SCbM0O1MuA2BIw== X-Received: by 2002:ac2:43dc:: with SMTP id u28mr417591lfl.17.1594846503041; Wed, 15 Jul 2020 13:55:03 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id m11sm642901ljb.47.2020.07.15.13.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 13:55:02 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 8D840102143; Wed, 15 Jul 2020 23:55:08 +0300 (+03) Date: Wed, 15 Jul 2020 23:55:08 +0300 From: "Kirill A. Shutemov" To: Linus Torvalds Cc: "Kirill A. Shutemov" , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Naresh Kamboju , Joel Fernandes , William Kucharski Subject: Re: [PATCHv2] mm: Fix warning in move_normal_pmd() Message-ID: <20200715205508.3rzrkhulruzpy6iv@box> References: <20200715135011.42743-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 2F7D33D669 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Wed, Jul 15, 2020 at 11:36:59AM -0700, Linus Torvalds wrote: > On Wed, Jul 15, 2020 at 6:50 AM Kirill A. Shutemov > wrote: > > > > mremap(2) does not allow source and destination regions to overlap, but > > shift_arg_pages() calls move_page_tables() directly and in this case the > > source and destination overlap often. It > > Actually, before we do this patch (which I think is a good idea), I'd > like Naresh to test the attached patch. > > And Kirill, Joel, mind looking it over too. I don't understand 'len' calculation in try_to_align_end(). IIUC, it increases 'len' by PMD_SIZE if 'new_addr+len' is not aligned to PMD_SIZE. It doesn't make sense to me. Maybe *len = roundup_up(*new_addr + *len, PMD_SIZE) - *new_addr; or something? BUT I *think* there's a bigger problem with the patch: For stack relocation case both VMAs are the same and always(?) the only VMA around at the time. It means none of ADDR_BEFORE_PREV and ADDR_AFTER_NEXT are going to stop us. Consider the following case, before and after try_to_align_start(): before after old_addr: 0x0123000 0x0000000 new_addr: 0x1123000 0x1000000 len: 0x1000000 0x1123000 (4k PAGE_SIZE, 2M PMD_SIZE) On the first iteration we would attempt to move 0x0-0x200000 to 0x1000000-0x1200000 and step onto the same WARN(), no? -- Kirill A. Shutemov