Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp758411ybh; Wed, 15 Jul 2020 14:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEYYxRgUCqRSpwX6xKe5vWYKmM3q8ACNkg89ihecz4ESVofn5jdEZSeW48oT/qA8wCmTpG X-Received: by 2002:a50:9e02:: with SMTP id z2mr1526723ede.87.1594848932754; Wed, 15 Jul 2020 14:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594848932; cv=none; d=google.com; s=arc-20160816; b=UZxUGkkPm87Jkzaw/Eb3v5KQ2l9O+ZhLYmbK8zLKd7OYch9UKlSMQAGUBf4DDYPo/0 O+j16GfOs6eMxOWozGATzcYHyKIgmswKv0BY12nnvMFassLyY57mNQlqwRvSm53Ou5ws LR13iY4cAHE0uIDKyX+SXY97GMvvGrwwOZuqSaUrFSGPfyBhH6v5wNqiBRDqfMHLAGEy CGlo3OnAFuC16wrzC+xMZ2BW6w7E5NObI2BbNELlqQa0DOHHdxql6eFP3XGh8/5TLzbA kIYxDIri4NZOH4c3a+LAWs2YhHa7nGiH1vuH4xEWkEe19LgAAZpWhkKOETMcXKDIkro/ YIbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Slsfcsh628hGH9fKIfCUDCo179zQ291O44Iubhz+iYw=; b=Kclxkg76oS1l349I3UFbbB0tSd3UFvNj1noHAkf54KAIbG0S3+Zwz/f/In2x0LaLUS wBuXlbjpsoiMKJXGNJLXWWhJfjVzCg9TD9q7PVoxQ9oJFmG3mm6iwl+ca5nzhOdH1nH7 XPCDD12ajjjx7Yl7iSXnVGLCjHrjBnRcnExer2YTEcDdki+mKyiTguSTDTIgRNZ+ri2h 1xEOCbzRuVRv1AWxK9WnwP+kfcLyTpkvfDgB5BA33+7McKAMvc8jwSAUL6x1CYcrHCnN eFdPwtx43mmb38Fd6KR6XnHI47OaZsT3CyrLgp8o2aLA7QfKLKuc+rtSpRbwgTAlmpxJ mnFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O4kkFWBF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si1934401edy.264.2020.07.15.14.35.09; Wed, 15 Jul 2020 14:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O4kkFWBF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbgGOVcP (ORCPT + 99 others); Wed, 15 Jul 2020 17:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgGOVcO (ORCPT ); Wed, 15 Jul 2020 17:32:14 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AD3C061755 for ; Wed, 15 Jul 2020 14:32:14 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id r19so4323823ljn.12 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=DyMuatnHUZKvxFxfCruDIy7C00jE5OIliJPkbNhGrVh6WJoDd6PQ43eNSOFiv8BDLY AXmW+yH5pN0C3fC8xxDhypUFP0fxC+zRFTtduSgYxK2uOOgUB4vkjqxnVu9tW3XOvuoy PVA7MiXxRvenDu+YUPMmwcrkawDx18w3+iwxqfrmt1bHzHI6VykSFKdz0jEj5ewYpWVY 7JQr0TRuHfftWW3lM1+8kHdxGgGbumUF6iF/8rqHNKKJoNAS69nWaYeq1+xpKE3my/tP ImXsw9SdkWH42sy/GlK2/JXP4giFTPnmSrjhqjmCOMT+pWVHgui6RkoAVvjVs89GSWXx nlCg== X-Gm-Message-State: AOAM5339rLuM9eVmozZ174MUjfBcPLW10Sg5gPo++cT0KIRt7SWSvgr7 4fxBajC89b9IrTGZMPJQxoIiBIiAkRU= X-Received: by 2002:a2e:8942:: with SMTP id b2mr461253ljk.412.1594848732421; Wed, 15 Jul 2020 14:32:12 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id o5sm883785lfg.27.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-f51.google.com with SMTP id y18so1924615lfh.11 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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