Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp953947ybl; Tue, 28 Jan 2020 15:36:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwYyVuY6TXJo1FKYywrC+wwSPYuVVeuvjEMiByTGVUtKWGAQH/T1JsCRVgEZMhF+6VSeV3E X-Received: by 2002:a05:6830:1116:: with SMTP id w22mr377752otq.216.1580254600177; Tue, 28 Jan 2020 15:36:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580254600; cv=none; d=google.com; s=arc-20160816; b=fFAQEEql5lj5rtBLxOPGaI5etFPkdLeouUfQnrE7LHytQoGLADu3NuFDhhH0IRygjy JNFV6STCP4aEPCl90z/y/qEnP3uMIC6NwFgi2LwuIw+CFak2WSW3g3LzNMxXhA5pdt9x ZHZukLp7DCWHWLlvwNUMcCu6281zkarl2iHJOr5vYPvJSCKb+237pg2hZZ4DuNextioE 1U0OZIwnmhjRm/wrsN/kAZRedQv0vTjM68Dpo33S5SYGLxRxSagSTkXtpuZnkmlpHcHa VGbBty2mInQ7MmHLniYhp9vsmNFAC9WGX+oHfJANy7+mX6TrMmg3CHTzCsi+6LDUdYuE Hbow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WJl749Ktrk8S85EaE4Qv0/+OYozg0DKw8o/BXFCqayo=; b=nAKK1TxCNxmOO+iFQ++SlrfWY9gkjCVxgw5IyWuUy2u8y9KP6leTT5mvZ+nOEPXT2P On9S25wLUogtk9qEAFi5yK7d/6B4+GiumsjIY8FizSjmTegSzb7Ys9Zo/Zh4q4fq1ddA WF1ZGu9P4CKKQMtIljz5JbK8HEi+3wP96dQ/+K4y6QXBcYfjza583W1pIwNDpos9uIBb qTRSgsg80ABGrVBoRXLJ2mtsF4e462jL6JAWENMgPJBwaxyC05l3N40nOwYMUIwARm6+ yDqfAf+HeCY0pZFbGzKfKW5H/ACsU1J0sdVjI8/PkQkYBbxYbf2PF+XSrJp0tMvjI/K7 HFqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oyvyrcS7; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si160469otj.24.2020.01.28.15.36.26; Tue, 28 Jan 2020 15:36:40 -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=@gmail.com header.s=20161025 header.b=oyvyrcS7; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726346AbgA1Xfa (ORCPT + 99 others); Tue, 28 Jan 2020 18:35:30 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39739 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbgA1Xfa (ORCPT ); Tue, 28 Jan 2020 18:35:30 -0500 Received: by mail-ed1-f65.google.com with SMTP id m13so16626624edb.6; Tue, 28 Jan 2020 15:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WJl749Ktrk8S85EaE4Qv0/+OYozg0DKw8o/BXFCqayo=; b=oyvyrcS78HjtjQmDKpaDThrcuGlf0fqwFsD6HxqoHKnJnXNrd5nZxKTAdl0TWE4C83 lLrT/yI77BFyeOtgdQFsd48Lz3EXps+S/go9uw4hxW23rN5GIgMS3PrbJcQenAgf3QM9 YRe1kVeFummLhrJ4QvWeNmER02/HW8u8dpDKhMdUVXPz6GKMfrbF/cvFihtgdhmaWAgL Uh6QgLriwPVdVFzKSmdrZenu2wuUlaWnbh95FBAkRIzNJw9Rtan1/YS/hZKhaY58yN/S u2vTMhK5OiVetJkcQk+b6W9hXcIxwbB0j/CcUX2NpKG0SngxBMe/JM5NNOy9d8qw88h6 16qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WJl749Ktrk8S85EaE4Qv0/+OYozg0DKw8o/BXFCqayo=; b=E3AyEnE1CasO5SpNL3yRRK3uztJza/SPfn8iKpB3E3/PIv+voFeibJfh7AC5nstOUM +hr/yH/t4khj0PcSRWllqjrYaMLoRAK9ekK1Bv6zTA68j5dqekuH5nvyRwmuimZsuZzc sMVqRO8tr+ohw7p9GZGufdmkFtjgoaKvteGjQxUl0Ke+RQkYBc2GkvZrPAxF2rTwgcYQ AfAp4pvOSldONPZUFiHtss7VnhEUtXDbSrC3KcT9S4Aj3bHJkW0Pky98JpesJZQKMtFc /jzPL686k9V6FIiQFkRnjw9W8doDs/56Y464InOaSZUqTXhpm063VEbLEx08Fue2jiph 79Cw== X-Gm-Message-State: APjAAAVXuuq/fs/NasgFaY6MfWAWeGj74mUzltz9XGM44Gyrnmuyvoaa rNtXc8eUd2nFlUlwIeyuuMg= X-Received: by 2002:a50:d849:: with SMTP id v9mr5816511edj.105.1580254528357; Tue, 28 Jan 2020 15:35:28 -0800 (PST) Received: from [192.168.2.145] (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.googlemail.com with ESMTPSA id v8sm198edw.21.2020.01.28.15.35.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jan 2020 15:35:27 -0800 (PST) Subject: Re: [PATCH 3/5] mm/mremap: use pmd_addr_end to calculate next in move_page_tables() To: Wei Yang Cc: Russell King - ARM Linux , akpm@linux-foundation.org, dan.j.williams@intel.com, aneesh.kumar@linux.ibm.com, kirill@shutemov.name, yang.shi@linux.alibaba.com, thellstrom@vmware.com, Thierry Reding , Jon Hunter , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "linux-tegra@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" References: <20200117232254.2792-1-richardw.yang@linux.intel.com> <20200117232254.2792-4-richardw.yang@linux.intel.com> <7147774a-14e9-4ff3-1548-4565f0d214d5@gmail.com> <20200128004301.GD20624@richard> <20200128232907.GA11467@richard> From: Dmitry Osipenko Message-ID: <27b70b0c-7945-cc85-8321-d9e4b6f17865@gmail.com> Date: Wed, 29 Jan 2020 02:35:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200128232907.GA11467@richard> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 29.01.2020 02:29, Wei Yang пишет: > On Tue, Jan 28, 2020 at 06:59:48PM +0300, Dmitry Osipenko wrote: >> 28.01.2020 03:43, Wei Yang пишет: >>> On Sun, Jan 26, 2020 at 05:47:57PM +0300, Dmitry Osipenko wrote: >>>> 18.01.2020 02:22, Wei Yang пишет: >>>>> Use the general helper instead of do it by hand. >>>>> >>>>> Signed-off-by: Wei Yang >>>>> --- >>>>> mm/mremap.c | 7 ++----- >>>>> 1 file changed, 2 insertions(+), 5 deletions(-) >>>>> >>>>> diff --git a/mm/mremap.c b/mm/mremap.c >>>>> index c2af8ba4ba43..a258914f3ee1 100644 >>>>> --- a/mm/mremap.c >>>>> +++ b/mm/mremap.c >>>>> @@ -253,11 +253,8 @@ unsigned long move_page_tables(struct vm_area_struct *vma, >>>>> >>>>> for (; old_addr < old_end; old_addr += extent, new_addr += extent) { >>>>> cond_resched(); >>>>> - next = (old_addr + PMD_SIZE) & PMD_MASK; >>>>> - /* even if next overflowed, extent below will be ok */ >>>>> + next = pmd_addr_end(old_addr, old_end); >>>>> extent = next - old_addr; >>>>> - if (extent > old_end - old_addr) >>>>> - extent = old_end - old_addr; >>>>> old_pmd = get_old_pmd(vma->vm_mm, old_addr); >>>>> if (!old_pmd) >>>>> continue; >>>>> @@ -301,7 +298,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma, >>>>> >>>>> if (pte_alloc(new_vma->vm_mm, new_pmd)) >>>>> break; >>>>> - next = (new_addr + PMD_SIZE) & PMD_MASK; >>>>> + next = pmd_addr_end(new_addr, new_addr + len); >>>>> if (extent > next - new_addr) >>>>> extent = next - new_addr; >>>>> move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma, >>>>> >>>> >>>> Hello Wei, >>>> >>>> Starting with next-20200122, I'm seeing the following in KMSG on NVIDIA >>>> Tegra (ARM32): >>>> >>>> BUG: Bad rss-counter state mm:(ptrval) type:MM_ANONPAGES val:190 >>>> >>> >>> Thanks. >>> >>> Would you mind letting me know which case you are testing? >> >> Nothing special, systemd starts to fall apart during boot. >> >>> Or the special thing is 32-bit platform? >> I have a limited knowledge about mm/, so can't provide detailed explanation. >> >> Please take a look at this: >> >> [1] >> https://elixir.bootlin.com/linux/v5.5/source/arch/arm/include/asm/pgtable-2level.h#L210 >> >> [2] >> https://elixir.bootlin.com/linux/v5.5/source/include/asm-generic/pgtable.h#L549 >> >> [3] >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c0ba10b512eb2e2a3888b6e6cc0e089f5e7a191b > > Thanks, I see the difference here. > > If this is the case, we can't use pmd_addr_end() to simplify the calculation. > This changes the behavior. > > I would prepare another patch set to fix this. Would you mind helping me > verify on your platform? Sure, please feel free to CC me on that patch.