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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 80ABAC33CB3 for ; Tue, 14 Jan 2020 10:02:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4FC912465B for ; Tue, 14 Jan 2020 10:02:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FC912465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B0AE38E000B; Tue, 14 Jan 2020 05:02:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB83C8E000A; Tue, 14 Jan 2020 05:02:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959218E000B; Tue, 14 Jan 2020 05:02:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 799668E0009 for ; Tue, 14 Jan 2020 05:02:32 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 36E19181AC9BF for ; Tue, 14 Jan 2020 10:02:32 +0000 (UTC) X-FDA: 76375800144.25.sleet72_16133d605e461 X-HE-Tag: sleet72_16133d605e461 X-Filterd-Recvd-Size: 5724 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jan 2020 10:02:31 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00EA23Pg081517; Tue, 14 Jan 2020 05:02:07 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xfavytyd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2020 05:02:06 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 00EA075d020269; Tue, 14 Jan 2020 10:01:56 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma02dal.us.ibm.com with ESMTP id 2xf74p13k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2020 10:01:55 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00EA1sED50921896 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jan 2020 10:01:54 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 935E5C6057; Tue, 14 Jan 2020 10:01:54 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A37FC605A; Tue, 14 Jan 2020 10:01:52 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.105]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 14 Jan 2020 10:01:51 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, peterz@infradead.org, will@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH v3 0/9] Fixup page directory freeing Date: Tue, 14 Jan 2020 15:31:36 +0530 Message-Id: <20200114100145.365527-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-14_02:2020-01-13,2020-01-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 suspectscore=2 adultscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=487 bulkscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001140090 Content-Transfer-Encoding: quoted-printable 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: This is a repost of patch series from Peter with the arch specific change= s except ppc64 dropped. ppc64 changes are added here because we are redoing the patch series on t= op of ppc64 changes. This makes it easy to backport these changes. Only the first 3 patches need to be backp= orted to stable.=20 The thing is, on anything SMP, freeing page directories should observe th= e exact same order as normal page freeing: 1) unhook page/directory 2) TLB invalidate 3) free page/directory Without this, any concurrent page-table walk could end up with a Use-afte= r-Free. This is esp. trivial for anything that has software page-table walkers (HAVE_FAST_GUP / software TLB fill) or the hardware caches partial page-w= alks (ie. caches page directories). Even on UP this might give issues since mmu_gather is preemptible these d= ays. An interrupt or preempted task accessing user pages might stumble into th= e free page if the hardware caches page directories. This patch series fixup ppc64 and add generic MMU_GATHER changes to suppo= rt the conversion of other architectures. I haven't added patches w.r.t other architecture because they are yet to = be acked. Aneesh Kumar K.V (1): powerpc/mmu_gather: Enable RCU_TABLE_FREE even for !SMP case Peter Zijlstra (8): mm/mmu_gather: Invalidate TLB correctly on batch allocation failure and flush asm-generic/tlb: Avoid potential double flush asm-gemeric/tlb: Remove stray function declarations asm-generic/tlb: Add missing CONFIG symbol asm-generic/tlb: Rename HAVE_RCU_TABLE_FREE asm-generic/tlb: Rename HAVE_MMU_GATHER_PAGE_SIZE asm-generic/tlb: Rename HAVE_MMU_GATHER_NO_GATHER asm-generic/tlb: Provide MMU_GATHER_TABLE_FREE arch/Kconfig | 13 +- arch/arm/Kconfig | 2 +- arch/arm/include/asm/tlb.h | 4 - arch/arm64/Kconfig | 2 +- arch/powerpc/Kconfig | 5 +- arch/powerpc/include/asm/book3s/32/pgalloc.h | 8 -- arch/powerpc/include/asm/book3s/64/pgalloc.h | 2 - arch/powerpc/include/asm/nohash/pgalloc.h | 8 -- arch/powerpc/include/asm/tlb.h | 11 ++ arch/powerpc/mm/book3s64/pgtable.c | 7 - arch/s390/Kconfig | 4 +- arch/sparc/Kconfig | 3 +- arch/sparc/include/asm/tlb_64.h | 9 ++ arch/x86/Kconfig | 2 +- arch/x86/include/asm/tlb.h | 4 +- include/asm-generic/tlb.h | 120 ++++++++++------- mm/gup.c | 2 +- mm/mmu_gather.c | 134 +++++++++++++------ 18 files changed, 207 insertions(+), 133 deletions(-) --=20 2.24.1