From patchwork Sun Aug 2 19:12:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11696841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CAB5913 for ; Sun, 2 Aug 2020 19:13:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D9DE62075B for ; Sun, 2 Aug 2020 19:12:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jtubiScP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9DE62075B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB0D08D00CB; Sun, 2 Aug 2020 15:12:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D622E8D00AA; Sun, 2 Aug 2020 15:12:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9FA48D00CB; Sun, 2 Aug 2020 15:12:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id B53C38D00AA for ; Sun, 2 Aug 2020 15:12:58 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 228311EE6 for ; Sun, 2 Aug 2020 19:12:58 +0000 (UTC) X-FDA: 77106576036.26.cloud41_3516de626f97 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id EBDCB1804B661 for ; Sun, 2 Aug 2020 19:12:57 +0000 (UTC) X-Spam-Summary: 1,0,0,0713fdf9c3d6195f,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:966:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3871:3872:3874:4321:4385:5007:6119:6261:6653:7903:10004:10400:11026:11658:11914:12043:12114:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13161:13229:13311:13357:13439:14096:14097:14181:14394:14659:14721:21080:21444:21451:21611:21627:30003:30054:30091,0,RBL:209.85.219.68:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yfjtt9sj3j56pdn7h97cgzwdyuxyc3q6a1x8xtuc9bqf63qum4cajpzft3dbj.9znegkypxtani3fqwws19cj3dwm5mdc5o8z41ww4oqin683ywmrpdmzm3bkgptb.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: cloud41_3516de626f97 X-Filterd-Recvd-Size: 4367 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Sun, 2 Aug 2020 19:12:57 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id s15so11997817qvv.7 for ; Sun, 02 Aug 2020 12:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=XRgkO+pWg9WMheb+JuYC1vAI+vcvMh8iE4b2S931akA=; b=jtubiScPdbrW2+U7U+6jrzTShJ5Sg9yHdKlHM1Y9mq8Amalzwv74e6GjZougu1lAPc 9jt9PbyLvszkkyA/zS4V6TxdEyB7CRSqfWRdTy5+0/FDOSu2M+Eg65uPiICpGw66FFT/ wdG04xdsqcxbo/7I8N6ygrqr7/9x7bfS37nqSdZjOPHFLiVulebhs1apxLRFxD7nhaGN ErihAFyp0ylMXsZ8MGiWjvAsp3xJhmkQZ1bgcdhqfY/irbBnFXyH3UD5caeLp6s073gl TaFut4XXDirwV1fq1Zlg2fYrCQLtRjK5WoJWJsU6Vj/e9/tIQQCiIyC1t/G9IlJ+XHeZ rbSw== 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:user-agent :mime-version; bh=XRgkO+pWg9WMheb+JuYC1vAI+vcvMh8iE4b2S931akA=; b=YBMMqYNCqI+EewLVHaroOUDm5F72U6L15XDppoEygOXP5m5bVIIUiD9u15cTqo9abl 4jGCJXTxM2480pURRzSWk2HZOJqiHRCRi4ju+6mE+G34Ii4n7WqQzqleRCTK13gKrWDR 57tNhaLBCi3azMfSgy0kpDywlmRDRaa6oUMrhrhZm/zQprOwIIeRt/4KvdzixuYcwuXI AdfPO+AE55fukA85VwJC4ZAlr2t5p9kSKaA+Cy4j9Nbk+aY5S0zfKmfaMkg/kfyF8eGh NyNiSKmkw2rWmWA/IFeB+7SPM7gm4BtE+0CdG9Wg85oAaxj4wm3NKyqzPQzzO521owO0 hhfw== X-Gm-Message-State: AOAM533ghT+ujNdAinuCmhljZA1EMQY6ShS+JcoPlgGOuh9zEEqJYhIa u+4H9jG6VxbocUSRudUfyAy+fQ== X-Google-Smtp-Source: ABdhPJx3nuFaSj5OTZQhiVFDS8UmH+7MuU+YZgjvS3G55rBmDRWqt8Q81TxAunQoMIQS7xaozuHgbw== X-Received: by 2002:ad4:41c9:: with SMTP id a9mr13360158qvq.171.1596395576614; Sun, 02 Aug 2020 12:12:56 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id g21sm18668943qts.18.2020.08.02.12.12.54 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Sun, 02 Aug 2020 12:12:55 -0700 (PDT) Date: Sun, 2 Aug 2020 12:12:42 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: "Kirill A. Shutemov" , Andrea Arcangeli , Song Liu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] khugepaged: collapse_pte_mapped_thp() flush the right range Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: EBDCB1804B661 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: pmdp_collapse_flush() should be given the start address at which the huge page is mapped, haddr: it was given addr, which at that point has been used as a local variable, incremented to the end address of the extent. Found by source inspection while chasing a hugepage locking bug, which I then could not explain by this. At first I thought this was very bad; then saw that all of the page translations that were not flushed would actually still point to the right pages afterwards, so harmless; then realized that I know nothing of how different architectures and models cache intermediate paging structures, so maybe it matters after all - particularly since the page table concerned is immediately freed. Much easier to fix than to think about. Fixes: 27e1f8273113 ("khugepaged: enable collapse pmd for pte-mapped THP") Signed-off-by: Hugh Dickins Cc: stable@vger.kernel.org # v5.4+ Acked-by: Kirill A. Shutemov --- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 5.8-rc7/mm/khugepaged.c 2020-07-26 16:58:02.189038680 -0700 +++ linux/mm/khugepaged.c 2020-08-02 10:48:59.890925896 -0700 @@ -1502,7 +1502,7 @@ void collapse_pte_mapped_thp(struct mm_s /* step 4: collapse pmd */ ptl = pmd_lock(vma->vm_mm, pmd); - _pmd = pmdp_collapse_flush(vma, addr, pmd); + _pmd = pmdp_collapse_flush(vma, haddr, pmd); spin_unlock(ptl); mm_dec_nr_ptes(mm); pte_free(mm, pmd_pgtable(_pmd));