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.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E2D89C433E6 for ; Wed, 15 Jul 2020 21:32:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 958102065F for ; Wed, 15 Jul 2020 21:32:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="O4kkFWBF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 958102065F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0CDD56B0002; Wed, 15 Jul 2020 17:32:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07DB06B0005; Wed, 15 Jul 2020 17:32:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E872E6B0006; Wed, 15 Jul 2020 17:32:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id D45C06B0002 for ; Wed, 15 Jul 2020 17:32:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 49FF78248047 for ; Wed, 15 Jul 2020 21:32:15 +0000 (UTC) X-FDA: 77041608630.15.pie85_470f99d26efc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 1B3451814B0C8 for ; Wed, 15 Jul 2020 21:32:15 +0000 (UTC) X-HE-Tag: pie85_470f99d26efc X-Filterd-Recvd-Size: 5020 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 21:32:14 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id x9so4393154ljc.5 for ; Wed, 15 Jul 2020 14:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Slsfcsh628hGH9fKIfCUDCo179zQ291O44Iubhz+iYw=; b=O4kkFWBFfS6AruYdFO2kccl5YLYkpVV48bmKKxenxXHKgGnD1JdBpgnOWobKutjQy3 Y7HEUJ2/gu9Dzu/XAqMuW+dp94DFj9wAenMyRxasT9IGWFCeOWvoZAgmbKy7oaq5TpSc JOtsiI5wdnX+7TiicHV1PBecF7rxvi0SyEcN0= 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=Slsfcsh628hGH9fKIfCUDCo179zQ291O44Iubhz+iYw=; b=FirYLI9MLpAVPx1p0KZ2WU0e7DLlajBvoyV4ObfGsxPffxBzsKYgebtal/djz12/85 DDLgVviM0bkoLMeKqVMX266+ZHZ76Lsxtq6DYsoYQla/t/nShSpTnHYb3aXz+rGR5yrg 3nbUc1/Q0WglepI+zJBO+mCfmaTwlm/Hir89kWZU0L02pPzHoxSaiDaRjbgxJh2HwCWH TKEesSu4EOQZVVLZvUjbkRNEUhcyiudCpm9VAo/38nT7N/8ZxI4HHx2Kibg/BPyVVVO/ +x4RXKdxWYpFyEgCZS5cFdUV5lYq7cM+pbxivS+DirVSUXw4Mbtd3TeOkD9yUFNumcjj PrtQ== X-Gm-Message-State: AOAM533YT0KZtJH+USGL/gRC9Eb97kSmP6qZMv2Cc5BGz2aVvNH5SkO2 mOKNwN6kakkcmfzxGvqOohPnROXeiXQ= X-Google-Smtp-Source: ABdhPJxRnSSUmE28WHPyK2p5NAH5VRJUvT4f9XA3smWxXojADK5t/sIQIxhXBDoRvO8g08DtNxiPqQ== X-Received: by 2002:a2e:b4d8:: with SMTP id r24mr495848ljm.19.1594848732629; Wed, 15 Jul 2020 14:32:12 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id 83sm657199ljj.51.2020.07.15.14.32.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jul 2020 14:32:11 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id s16so1929146lfp.12 for ; Wed, 15 Jul 2020 14:32:10 -0700 (PDT) X-Received: by 2002:a19:8a07:: with SMTP id m7mr475815lfd.31.1594848730272; Wed, 15 Jul 2020 14:32:10 -0700 (PDT) MIME-Version: 1.0 References: <20200715135011.42743-1-kirill.shutemov@linux.intel.com> <20200715205428.GA201569@google.com> In-Reply-To: <20200715205428.GA201569@google.com> From: Linus Torvalds Date: Wed, 15 Jul 2020 14:31:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2] mm: Fix warning in move_normal_pmd() To: Joel Fernandes Cc: "Kirill A. Shutemov" , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Naresh Kamboju , William Kucharski Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 1B3451814B0C8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 1:54 PM Joel Fernandes wrote: > > Regarding the ADDR_AFTER_NEXT checks, shouldn't you check for: > > if (ADDR_AFTER_NEXT(ALIGN(*old_addr + *len, PMD_SIZE), old)) > return; No, there's even a comment to the effect. Instead, that ADDR_AFTER_NEXT() aligns the next address _down_ to the PMD boundary. Because otherwise, what can happen is: - you're on an architecture that has a separate address space for users - you're the next-to-last VMA in that address space, - you're in the last PMD. And now "ALIGN(*old_addr + *len, PMD_SIZE)" will wrap, and become 0, and you think it's ok to move the whole PMD, because it's now smaller than the start address of the next VMA. It's _not_ ok, because you'd be moving that next-vma data too. > and for the len calculation, I did not follow what you did, but I think you > meant something like this? Does the following reduce to what you did? At > least this is a bit more readable I think: > > *len += (ALIGN(*new_addr + *len, PMD_SIZE) - (*new_addr + *len)); Yes, right you are. I actually wrote that first (except I added a helper variable for that "*new_addr + *len" thing), and then I decided it can be simplified. And simplified it wrong ;) > Also you did "len +=", it should be "*len +=" in this function. That's indeed a plain stupid bug ;) Naresh - don't test that version. The bugs Joel found just make the math wrong, so it won't work. The concept was solid, the implementation not so much ;) Linus