Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp783424ybh; Wed, 15 Jul 2020 15:25:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCVEPeJGvdtgpOTFNoHxzsflbySuU9RefgPjN/gvrwYiHLxaJDfEFBrRGV32q6Aov/zrrR X-Received: by 2002:aa7:c909:: with SMTP id b9mr1698839edt.111.1594851937662; Wed, 15 Jul 2020 15:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594851937; cv=none; d=google.com; s=arc-20160816; b=t/pA0kXihIvNosIMKjL7JX24YIwDdrUTo8u3HRPXBvf6I4mY7c2LkJKtAyd+Lnh4kY TTZhJe0Od34dUCnIOJI4jOuXP2Nyp8invCTSwdmBI3Vq9mWUa9HWbt+QRxeue1dPs/Ab +n6Oxl1x57UNvrg75QuKJF79UAuEStaFlzpoFvGeqrWCkDCie7aPavlhx37YFn2qVwKk o0H7c6yI/kvyS0bbizZvPzxHBQbXHytgDaDODp2/eqZIHKAB0jUtCQLvlZYBa8IW6MUb L+zcDvQXune4FtGawlMHTFWLK8CN1Vbn6geBNdjo7NSC/Kmkh4OxCGpdSwRIC1tLUshu 8t2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QQLzvz01x+b8v3+Cnyl7jGabL4vkvUR6NP/JnDRqN14=; b=RBbkiAv172qvTev0UkHRqa/Dgka251Bz1x2VLuThL0eaZSyrNhH9ktHonDzkShqtq8 P2OTuqQX0K3tcYLEQdZ8EAfnO82Bh6+NOcA8u8Ga/6g45Hv3LYwqyVypmaxE08BIXmTi IdYrKSeR5oxieilLjH6HrAeKIO98u/1zPAG7S5S34MzB29zphpDN9D/YYqNPDxB/rFBt m07io6a5qtz1LdsCdWctJFggJ6rNMCsT5dhE9qTNP8dBUp1xFsrKWP2eaGlVcIU/Ys7G 1VL27FDRUECzkdMMpMT3A5diUzT+hYWUDn/mKjSirB/p/EEHZnMxI5U89djtdOFqYpeu qUNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=t6qmthfa; 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 v21si2107352edw.286.2020.07.15.15.25.10; Wed, 15 Jul 2020 15:25:37 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=t6qmthfa; 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 S1726832AbgGOWWZ (ORCPT + 99 others); Wed, 15 Jul 2020 18:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbgGOWWY (ORCPT ); Wed, 15 Jul 2020 18:22:24 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB40C061755 for ; Wed, 15 Jul 2020 15:22:24 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id z24so4535041ljn.8 for ; Wed, 15 Jul 2020 15:22:24 -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=QQLzvz01x+b8v3+Cnyl7jGabL4vkvUR6NP/JnDRqN14=; b=t6qmthfa2lAn6qPwWRBsl1GYTeI7O9H+AGbAsb4IxmUyvEHHu7fJK1c224oXidHvmZ 5AMdfkj6yFJC2kHTm4TOyTPpVtA2o/xE9NjwHt7C60xpdfuBkE/teayYJacmxzGDOdZW oJbqNFfuBFbWTh5wzW6rl26wHAx82ioSAM5EtzXQUes5raOLOCYfkroCswbzjPxIlBUT /8QKGEclyi661apiOLbs3iuEf1mkRSBXZ/CqUrMD38x7aMkQz2OTITKPPn//QaYzYJfo W/iI5R7wgEGjK8RrMtshOmUBj6wl1smJGLhCZOoaQnxKC1hX619J7iHFGarIIARs5hPn 5exw== 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=QQLzvz01x+b8v3+Cnyl7jGabL4vkvUR6NP/JnDRqN14=; b=aDWQVAHykqkOmxXBw1GkToBGcshoZrfbpda2V2PNxgukWeSoGbzMue78WQYvx9PaB4 t6+6iKYvAwiMi/5POgXKy2a6XwfVJy4u8Wg8X3C5CWdHhm+PpbGtON9NMQu2+tc8ILo4 zSSR6H5asLCHGmBBOune/cuVG6zxBZhiOuJBfZap475F37gJDY16MlflIEa8cLDTZOsR 09ZqRHJzh+fjDk1flgLxRpY2QbakAV98E6GpfMEiHopO75InpHjPSXklI6F+rRS36M9B 9tvBQJQaMpKsfyFE2J8d1SI+7uLJmlwhQyx3mO+LymQ9zGcC2Tb2rWBdaBiYXcN9zsOn WSxw== X-Gm-Message-State: AOAM531/IVczgRpFYOA2I+T2QfhTF3CzXXDmh7emh6+k6lW4ugDI0ix2 Owj6aTAgVC3S5TAD+4E1Z35j2g== X-Received: by 2002:a2e:8046:: with SMTP id p6mr616358ljg.100.1594851742568; Wed, 15 Jul 2020 15:22:22 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id b16sm669040ljp.124.2020.07.15.15.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 15:22:22 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 5CB9C102143; Thu, 16 Jul 2020 01:22:28 +0300 (+03) Date: Thu, 16 Jul 2020 01:22:28 +0300 From: "Kirill A. Shutemov" To: Linus Torvalds Cc: Joel Fernandes , "Kirill A. Shutemov" , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Naresh Kamboju , William Kucharski Subject: Re: [PATCHv2] mm: Fix warning in move_normal_pmd() Message-ID: <20200715222228.jf2pv5u2wyhtc5o5@box> References: <20200715135011.42743-1-kirill.shutemov@linux.intel.com> <20200715205428.GA201569@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 02:43:00PM -0700, Linus Torvalds wrote: > On Wed, Jul 15, 2020 at 2:31 PM Linus Torvalds > wrote: > > > > Naresh - don't test that version. The bugs Joel found just make the > > math wrong, so it won't work. > > Here's a new version with the thing that Joel and Kirill both noticed > hopefully fixed. > > But I probably screwed it up again. I guess I should test it, but I > don't have any really relevant environment (the plain mremap() case > should have shown the obvious bugs, though, so that's just an excuse > for my laziness) Sorry, but the patch is broken. It overcopies entires in some cases. It doesn't handles correctly if you try to move PTEs from the middle of VMA. The test case below rightly sigfaults without the patch when trying access DST_ADDR[0], but not with the patch. It creates PTE entry at DST_ADDR that doesn't belong to any VMA. :/ #define _GNU_SOURCE #include #include #include #define SRC_ADDR ((char *)(4UL << 30)) #define DST_ADDR ((char *)(5UL << 30)) int main(void) { mmap(SRC_ADDR, 2UL << 20, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); madvise(SRC_ADDR, 2UL << 20, MADV_NOHUGEPAGE); memset(SRC_ADDR, 0x33, 2UL << 20); mremap(SRC_ADDR + 4096, 4096, 4096, MREMAP_MAYMOVE | MREMAP_FIXED, DST_ADDR + 4096); printf("0: %#x 4096: %#x\n", DST_ADDR[0], DST_ADDR[4096]); return 0; } -- Kirill A. Shutemov