From patchwork Mon Oct 15 16:42:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schwidefsky X-Patchwork-Id: 10642187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8925817D2 for ; Mon, 15 Oct 2018 16:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77A04299C2 for ; Mon, 15 Oct 2018 16:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B66529A7E; Mon, 15 Oct 2018 16:43:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AD19299C2 for ; Mon, 15 Oct 2018 16:43:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1D0F6B000E; Mon, 15 Oct 2018 12:43:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ED1976B0010; Mon, 15 Oct 2018 12:43:01 -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 D70DE6B0266; Mon, 15 Oct 2018 12:43:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by kanga.kvack.org (Postfix) with ESMTP id A402F6B000E for ; Mon, 15 Oct 2018 12:43:01 -0400 (EDT) Received: by mail-ot1-f69.google.com with SMTP id y22so15026331oty.3 for ; Mon, 15 Oct 2018 09:43:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id :content-transfer-encoding:mime-version; bh=ZdL44n1JUPf+c1JIzw+vN9g/+ptREVygpPDXPQQdW4g=; b=jB8TqC+d8O7xf/5LTyCjCSBgS2MBlGNbPG8ygZ3qfREbFDAW1uTh1wWjU8LvRZsJzh 6fd1VL2LUfIkFGGkWFNYsyUBmJCz2wq3TnP5Vewb23vfKW+nqe9x8Itx+2sRaeIubhP3 nhwJwIGDgDZu8iecmVfAS5ElkYncCECymUBfKY1mwepZ87g3sz9MmA8BumyoHODU+Z9o wo3MwulgNbHt/mTLlzRA/s5T6yBiZSDzZCtx+QtLW92NhE5QyL30Qk6NQzJi5Qo6P732 1fZFWC1pTFpoBQJzZlmA+grVsbbwaa2jVlCa1pVd9E2vB/2WlUfOW0xt5WfgdbAwTSAC eibA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: ABuFfogQRmYX3tcosZ8M6ISZbbTOh83AZITDALy4jcZm7f7WxGFF/0Qc aD622ZKIAZBtkBsYu9Emy/GnDbvisdMV7HJ72miiR8UUs0AgzPGvtRUg/T8exnKZ/rXCg1AZsef yqwzqW9xYaB8cW1wXTreeB4MIeymy0gkzWq/Thb+67G4JXwWpfQgm56oedT1uI+AUSQ== X-Received: by 2002:aca:dbc1:: with SMTP id s184-v6mr8976773oig.109.1539621781357; Mon, 15 Oct 2018 09:43:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV600UkoblqpqsXcNmh3OY3qsqyihZt29EROC7/WCwqwi1bhvAArjGo9EUX68+GcSc6z/YJna X-Received: by 2002:aca:dbc1:: with SMTP id s184-v6mr8976742oig.109.1539621780678; Mon, 15 Oct 2018 09:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539621780; cv=none; d=google.com; s=arc-20160816; b=RSU3rllo9X0Pl8OkTCFbTgQzP+0Brw9nDq57X2e9WKQKdfH+nUs5//9YixlTjwnjCz xpz2e1YNsUa3fEvDUN80jIU93WECoWYd+eY9COAK7WFz225A5KB+xGxoHOQjjk6K5JSz xeOSa0IQONXjo/B90RPZg2FOGfgygKkqejEZYVcUIrO2Oxu/ZAUnjnQSmDvp86RGpv6O 9dzECONTxEx22feNHhEoPg1++T5UEWvCIcaTl+0gQf1IjZbA78u8X0s5CMfU9kbKDwFF ZBe28kEuzERZqGxbn9Wq8q0dQ+t9ItqDvPkDWb2fN4uZn0YWq2bM/5Gj/KXykBkP4PuT j93w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:message-id:references :in-reply-to:date:subject:cc:to:from; bh=ZdL44n1JUPf+c1JIzw+vN9g/+ptREVygpPDXPQQdW4g=; b=ySLwvx/l5iQkfKhGbN173J4csdQjV+XXYhgzHF/SsRyHN6KzWIgZhEiLXYFMgiXd5w xqQUjlvXBD1eAc5ySUne9kc46VNu20UBp6gmIz2Oa/u9uiRa6nY+cQnUjvzdbkVbXL67 wEUpuIVM2qcb6rD7GXwunPzdeGRx772XLIY1x/yrddLRAbjjrqYvVZ0b/1EpflEsvsOL VcbzDHWuSBPi+ZHZD8q8TdXAaxtblaXGhWFia2GyyCzqhxGPEVZX0KmXKHYtDAT1vWwT ECZaii4mmZkoEsOjuOalsTlqqsHE5Ms873MOa7diyNqoYaxigc7M9mn3NcYrKTCQWYu2 27ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id y17si4648178otg.75.2018.10.15.09.43.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 09:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9FGeikN014865 for ; Mon, 15 Oct 2018 12:43:00 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n4w9suyhb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Oct 2018 12:42:59 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Oct 2018 17:42:57 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Oct 2018 17:42:53 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9FGgqSg4784628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Oct 2018 16:42:52 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C31442045; Mon, 15 Oct 2018 19:42:26 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E5A94203F; Mon, 15 Oct 2018 19:42:26 +0100 (BST) Received: from mschwideX1.emea.ibm.com (unknown [9.145.33.55]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 15 Oct 2018 19:42:26 +0100 (BST) From: Martin Schwidefsky To: Li Wang , Guenter Roeck , Janosch Frank Cc: "Kirill A. Shutemov" , Heiko Carstens , linux-kernel , Linux-MM , Martin Schwidefsky Subject: [PATCH 1/3] mm: introduce mm_[p4d|pud|pmd]_folded Date: Mon, 15 Oct 2018 18:42:37 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> References: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101516-0012-0000-0000-000002B75875 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101516-0013-0000-0000-000020EBC9DC Message-Id: <1539621759-5967-2-git-send-email-schwidefsky@de.ibm.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-15_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=701 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810150147 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: X-Virus-Scanned: ClamAV using ClamSMTP Add three architecture overrideable function to test if the p4d, pud, or pmd layer of a page table is folded or not. Signed-off-by: Martin Schwidefsky --- include/linux/mm.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0416a7204be3..d1029972541c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -105,6 +105,46 @@ extern int mmap_rnd_compat_bits __read_mostly; #define mm_zero_struct_page(pp) ((void)memset((pp), 0, sizeof(struct page))) #endif +/* + * On some architectures it depends on the mm if the p4d/pud or pmd + * layer of the page table hierarchy is folded or not. + */ +#ifndef mm_p4d_folded +#define mm_p4d_folded(mm) mm_p4d_folded(mm) +static inline bool mm_p4d_folded(struct mm_struct *mm) +{ +#ifdef __PAGETABLE_P4D_FOLDED + return 1; +#else + return 0; +#endif +} +#endif + +#ifndef mm_pud_folded +#define mm_pud_folded(mm) mm_pud_folded(mm) +static inline bool mm_pud_folded(struct mm_struct *mm) +{ +#ifdef __PAGETABLE_PUD_FOLDED + return 1; +#else + return 0; +#endif +} +#endif + +#ifndef mm_pmd_folded +#define mm_pmd_folded(mm) mm_pmd_folded(mm) +static inline bool mm_pmd_folded(struct mm_struct *mm) +{ +#ifdef __PAGETABLE_PMD_FOLDED + return 1; +#else + return 0; +#endif +} +#endif + /* * Default maximum number of active map areas, this limits the number of vmas * per mm struct. Users can overwrite this number by sysctl but there is a From patchwork Mon Oct 15 16:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schwidefsky X-Patchwork-Id: 10642185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9446925 for ; Mon, 15 Oct 2018 16:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B91FC299C2 for ; Mon, 15 Oct 2018 16:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACA9E29A7E; Mon, 15 Oct 2018 16:43:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3890A299C2 for ; Mon, 15 Oct 2018 16:43:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 141EA6B000C; Mon, 15 Oct 2018 12:43:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 077DC6B000D; Mon, 15 Oct 2018 12:43:01 -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 DE4826B000E; Mon, 15 Oct 2018 12:43:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id B2ED36B000C for ; Mon, 15 Oct 2018 12:43:00 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id f8-v6so10913521ybn.22 for ; Mon, 15 Oct 2018 09:43:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id :content-transfer-encoding:mime-version; bh=41BP0a+7aEgZHWhOJ0ag8aX2ghfs6RYBSlvVHzfWQtw=; b=LIpqrQHA7tilt7ihxKIGaJdXQEwH4n+mL1ypd7xGSJL6hOlwDQxdhGGDGqa5rryVmJ gy8dVsPUkhiMAZuDiSGmxD4V/4CO8lwaf92ut0pK6F6TssDFAqmrB5ku3cULx5ydKRRR X4KPWJ517SUIsg8nwWfV/CwbJCfUH2FrwVomEiAFER7S49RCuUVPW4m5chaW+7TJphQF 48/iVRaYgkm68jdpHpa43LiIrQ42xMHdVMcA/fKxe9th9VJkK02XPKduIYW3HCg2GJ67 ULZoShvHOSmVgGiDVabHj1cc+dcF6mBKR3OfqEZfjvxdlHoKoAOCSksfwP2hTWduZ4lj +X7g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: ABuFfogThSpgZmeVnIrqzYyhiwe0vI9JRU6cCOF2xEdTxV8rzVHJJP11 Cowry6UdttMvN9/64A1Q2WOvKQvDrujlxiDi23ngdE+yUI/H2ZERpeUlJN5n4UAMJgcCF8+HsAE pgHMQf8Pal5sWKFCjQufoIRKhoompRHVvEC4YPGQtCNn8gsAhn7zAAThzfO5gfbxMRg== X-Received: by 2002:a25:c8c2:: with SMTP id y185-v6mr9384862ybf.375.1539621780322; Mon, 15 Oct 2018 09:43:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV639uIVMXklKTG13DT23j0U4y9QA51wsLWFLaIlG2KY8BpVgHVnu+YAgKheihsvwBhkGGc+5 X-Received: by 2002:a25:c8c2:: with SMTP id y185-v6mr9384831ybf.375.1539621779657; Mon, 15 Oct 2018 09:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539621779; cv=none; d=google.com; s=arc-20160816; b=PuYeaWf+7ejN5aIto0j5P7e5N3zSrpzPl8rl/nTakirRtNlt17Rh/FY8QWRttym41Y 7VW14hWJNkIKuumhsxyLQy0k17piJFhY9rjOeGOzOcF3QWz1Rul5S8vh5r+Drr9OsRLI gYgAkJp5tcP1kLQ4jwPK0oggXuAsHvJgjMSExV1IGvLEB2Zd99PIeob80+l4655MHeEH HphHhwiRrgW270SfY/AyJWJrISu0HVxGc05Avb/3OicdW4iQiDyRV3X+MOidDo0Y13LB zby11Yra9a/1c8xV5KgcZ99fS/eb/zoaw6eA8tSrHAxTtScMbLHL6doqQJ+WE5DKnECR hoZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:message-id:references :in-reply-to:date:subject:cc:to:from; bh=41BP0a+7aEgZHWhOJ0ag8aX2ghfs6RYBSlvVHzfWQtw=; b=eNBkI3NtGWvcIr37Y8JlVucUuU+0N1GMrKJUN/0NP66lDEnm6HTH3lVyTkpsEdMpp8 +1zLu/MVLz+fJwzZxD1+LsOpC4bDkD4p0+rKMo44bJireVXCtB9Vpe53/h5yaBo4wXiX sSOux0+3vmg0Zr6Q/vT+8fRS160lbaklJjMehyvtoBKBoPJb0+R6Tdqh5yaT3Wc4ObvZ lJNheMa7YnmLRNa2Dm4JNbag11TRA+2RybhVRB7YifvfqOs2iV2Oa16B/C249/F5Kkip 1wq22KyLQUHSrNgPWust6dOzKfGm+RJP5SSBCx5luO2B85/HpdyCrrc7HmAHKLtllRMN e0oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id t136-v6si4154912ywe.315.2018.10.15.09.42.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 09:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9FGeS6h176440 for ; Mon, 15 Oct 2018 12:42:59 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2n4vr2wywd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Oct 2018 12:42:59 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Oct 2018 17:42:57 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Oct 2018 17:42:55 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9FGgsLJ60817446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Oct 2018 16:42:54 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB2834203F; Mon, 15 Oct 2018 19:42:27 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D0B842045; Mon, 15 Oct 2018 19:42:27 +0100 (BST) Received: from mschwideX1.emea.ibm.com (unknown [9.145.33.55]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 15 Oct 2018 19:42:27 +0100 (BST) From: Martin Schwidefsky To: Li Wang , Guenter Roeck , Janosch Frank Cc: "Kirill A. Shutemov" , Heiko Carstens , linux-kernel , Linux-MM , Martin Schwidefsky Subject: [PATCH 2/3] mm: add mm_pxd_folded checks to pgtable_bytes accounting functions Date: Mon, 15 Oct 2018 18:42:38 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> References: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101516-0028-0000-0000-00000307ADB8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101516-0029-0000-0000-000023C2B51C Message-Id: <1539621759-5967-3-git-send-email-schwidefsky@de.ibm.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-15_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=673 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810150147 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: X-Virus-Scanned: ClamAV using ClamSMTP The common mm code calls mm_dec_nr_pmds() and mm_dec_nr_puds() in free_pgtables() if the address range spans a full pud or pmd. If mm_dec_nr_puds/mm_dec_nr_pmds are non-empty due to configuration settings they blindly subtract the size of the pmd or pud table from pgtable_bytes even if the pud or pmd page table layer is folded. Add explicit mm_[pmd|pud]_folded checks to the four pgtable_bytes accounting functions mm_inc_nr_puds, mm_inc_nr_pmds, mm_dec_nr_puds and mm_dec_nr_pmds. As the check for folded page tables can be overwritten by the architecture, this allows to keep a correct pgtable_bytes value for platforms that use a dynamic number of page table levels. Signed-off-by: Martin Schwidefsky Acked-by: Kirill A. Shutemov --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index d1029972541c..67f55c71e59a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1764,11 +1764,15 @@ int __pud_alloc(struct mm_struct *mm, p4d_t *p4d, unsigned long address); static inline void mm_inc_nr_puds(struct mm_struct *mm) { + if (mm_pud_folded(mm)) + return; atomic_long_add(PTRS_PER_PUD * sizeof(pud_t), &mm->pgtables_bytes); } static inline void mm_dec_nr_puds(struct mm_struct *mm) { + if (mm_pud_folded(mm)) + return; atomic_long_sub(PTRS_PER_PUD * sizeof(pud_t), &mm->pgtables_bytes); } #endif @@ -1788,11 +1792,15 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address); static inline void mm_inc_nr_pmds(struct mm_struct *mm) { + if (mm_pmd_folded(mm)) + return; atomic_long_add(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes); } static inline void mm_dec_nr_pmds(struct mm_struct *mm) { + if (mm_pmd_folded(mm)) + return; atomic_long_sub(PTRS_PER_PMD * sizeof(pmd_t), &mm->pgtables_bytes); } #endif From patchwork Mon Oct 15 16:42:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schwidefsky X-Patchwork-Id: 10642189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFB33925 for ; Mon, 15 Oct 2018 16:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFCE1299C2 for ; Mon, 15 Oct 2018 16:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D2729A7E; Mon, 15 Oct 2018 16:43:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A73B299C2 for ; Mon, 15 Oct 2018 16:43:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED4C56B0266; Mon, 15 Oct 2018 12:43:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E33C86B0269; Mon, 15 Oct 2018 12:43:04 -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 C5D566B026A; Mon, 15 Oct 2018 12:43:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by kanga.kvack.org (Postfix) with ESMTP id 951816B0266 for ; Mon, 15 Oct 2018 12:43:04 -0400 (EDT) Received: by mail-ot1-f69.google.com with SMTP id 36so14675615ott.22 for ; Mon, 15 Oct 2018 09:43:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id :content-transfer-encoding:mime-version; bh=fKxM1w0QaLugxcyHz5Ey948cZfC8a5DCkBSjucimHco=; b=p1CvW8xA04gHi2tPY7fbUb/BELSLQ8kxdoLA1hjwpOp5i1gvZfVDJeBPuCcAvfxfDX QxdI1qBPvRzJDxLVF3jstSDnJdJuPpC4XWmozmo9Gmzzre/z1z3zxgIofLN+9UXtAU6e daE4u8VNDXlQXbccTf3bimtS+szMnuVhzQLGOcq08NcI8iMaGX/Wx1F2auxf6aaD8nSG tDXEr0HlIRJ6FouQNearA8tFUEYH7tX/W90R496oPZIJScMcgjy1ieI1SBk64CqOdt2u XGf37qF3YTuRHjCyjMF5bCBLk8QD//B0/1JraBJEYCYVUQYuiCK9W02GyrIix0WoPmXy yj6A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: ABuFfojAGfX5a2D0troiS3TnCwSCCQkbnc3qJ2cqdRXUxeUQipyjvfwS CBA2JDdZDCNUZBnqwqiEQfs2B2ATCTfV/EkBHyBFX1pOCABC44JR0+mCQWgzHgj7V1q/Q7uOP5l 56zSOj0HIVUmM2vVvIqiU49XHTHqFPnz5HcKOlAmn4U+/Wp1YLYbb8tUf/wltgbPkBw== X-Received: by 2002:aca:a907:: with SMTP id s7-v6mr9035023oie.68.1539621784305; Mon, 15 Oct 2018 09:43:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV63cqrzxQaSyfLosKg+c0OiUXj8AVacfZiUs87BMGYTrfUu+dEjx8C6CcQNyVEl+N35halMg X-Received: by 2002:aca:a907:: with SMTP id s7-v6mr9034986oie.68.1539621783290; Mon, 15 Oct 2018 09:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539621783; cv=none; d=google.com; s=arc-20160816; b=XMHm8tkY7lgnfR1VeY1kEUk2HaVie5J7aFx9GxrhnyhVo/eqopjn75k3jRbzQO9l5i 2MZqPDePrzPHpoLDR3/55o+UVgc+AqwfSC6BHV4L4OtvVibbe1GlJANCbmny2epj306t NLAKJOKEA0Bct3vbxKnlFjZPGrUClf1rNoq0ng9KJoB61L47HWWvVqRjpwW4j1HUEoPU iUetd3NMi69QrU7m06rDQtlPWAPSiS8bfLDXoMCcTSRI3Pklxzd7d+7Y5Ee1emfhsJxa J3HPXRqtvGp0RBGkSxq4AIZwTTv5uARI9HiKeTZx3n9aJNIHYYB1NZNVh9WD9SldfHA4 lT1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:message-id:references :in-reply-to:date:subject:cc:to:from; bh=fKxM1w0QaLugxcyHz5Ey948cZfC8a5DCkBSjucimHco=; b=ajE/uYP4bENtiuKz5n+3eVWIe18cktf3I7H0tbYLlfnPhWlh/kn6s9mWKD2k3CadrS ulL6LgrLPJrVqeRRFazfnXMeJ42yip5FpDymrLVrdqHUvwQ/vKljodiDi0fA7VQ2+F+k A4xadydnpGYrntuA394nX5DHxcmKCioRXrj+rXo1JeV/ahYOLfuKF+HLxZl7/WW+nB7C 5N3qFTo0191Y9cRStc8DhhFqmGHtbv/j1WAZV2FKllbWVfqqL9wO8/Lw2BncD+fOUly5 QQCMguOWTV6mVCLImzguFPYg7nBU7+2Z6pjF/K4HT/R3gYamCKVgel+0Y2pnADki0808 bPhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id q14si4861349otn.214.2018.10.15.09.43.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 09:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of schwidefsky@de.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=schwidefsky@de.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9FGdl9A113439 for ; Mon, 15 Oct 2018 12:43:02 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n4vrwwsve-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Oct 2018 12:43:01 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Oct 2018 17:42:59 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Oct 2018 17:42:56 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9FGgtCN393482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Oct 2018 16:42:55 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37A6542047; Mon, 15 Oct 2018 19:42:29 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCD9A42042; Mon, 15 Oct 2018 19:42:28 +0100 (BST) Received: from mschwideX1.emea.ibm.com (unknown [9.145.33.55]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 15 Oct 2018 19:42:28 +0100 (BST) From: Martin Schwidefsky To: Li Wang , Guenter Roeck , Janosch Frank Cc: "Kirill A. Shutemov" , Heiko Carstens , linux-kernel , Linux-MM , Martin Schwidefsky Subject: [PATCH 3/3] s390/mm: fix mis-accounting of pgtable_bytes Date: Mon, 15 Oct 2018 18:42:39 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> References: <1539621759-5967-1-git-send-email-schwidefsky@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101516-0028-0000-0000-00000307ADB9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101516-0029-0000-0000-000023C2B51E Message-Id: <1539621759-5967-4-git-send-email-schwidefsky@de.ibm.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-15_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810150147 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: X-Virus-Scanned: ClamAV using ClamSMTP In case a fork or a clone system fails in copy_process and the error handling does the mmput() at the bad_fork_cleanup_mm label, the following warning messages will appear on the console: BUG: non-zero pgtables_bytes on freeing mm: 16384 The reason for that is the tricks we play with mm_inc_nr_puds() and mm_inc_nr_pmds() in init_new_context(). A normal 64-bit process has 3 levels of page table, the p4d level and the pud level are folded. On process termination the free_pud_range() function in mm/memory.c will subtract 16KB from pgtable_bytes with a mm_dec_nr_puds() call, but there actually is not really a pud table. One issue with this is the fact that pgtable_bytes is usually off by a few kilobytes, but the more severe problem is that for a failed fork or clone the free_pgtables() function is not called. In this case there is no mm_dec_nr_puds() or mm_dec_nr_pmds() that go together with the mm_inc_nr_puds() and mm_inc_nr_pmds in init_new_context(). The pgtable_bytes will be off by 16384 or 32768 bytes and we get the BUG message. The message itself is purely cosmetic, but annoying. To fix this override the mm_pmd_folded, mm_pud_folded and mm_p4d_folded function to check for the true size of the address space. Reported-by: Li Wang Signed-off-by: Martin Schwidefsky Tested-by: Li Wang Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/mmu_context.h | 5 ----- arch/s390/include/asm/pgalloc.h | 6 +++--- arch/s390/include/asm/pgtable.h | 18 ++++++++++++++++++ arch/s390/include/asm/tlb.h | 6 +++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h index 0717ee76885d..f1ab9420ccfb 100644 --- a/arch/s390/include/asm/mmu_context.h +++ b/arch/s390/include/asm/mmu_context.h @@ -45,8 +45,6 @@ static inline int init_new_context(struct task_struct *tsk, mm->context.asce_limit = STACK_TOP_MAX; mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_REGION3; - /* pgd_alloc() did not account this pud */ - mm_inc_nr_puds(mm); break; case -PAGE_SIZE: /* forked 5-level task, set new asce with new_mm->pgd */ @@ -62,9 +60,6 @@ static inline int init_new_context(struct task_struct *tsk, /* forked 2-level compat task, set new asce with new mm->pgd */ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; - /* pgd_alloc() did not account this pmd */ - mm_inc_nr_pmds(mm); - mm_inc_nr_puds(mm); } crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); return 0; diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h index f0f9bcf94c03..5ee733720a57 100644 --- a/arch/s390/include/asm/pgalloc.h +++ b/arch/s390/include/asm/pgalloc.h @@ -36,11 +36,11 @@ static inline void crst_table_init(unsigned long *crst, unsigned long entry) static inline unsigned long pgd_entry_type(struct mm_struct *mm) { - if (mm->context.asce_limit <= _REGION3_SIZE) + if (mm_pmd_folded(mm)) return _SEGMENT_ENTRY_EMPTY; - if (mm->context.asce_limit <= _REGION2_SIZE) + if (mm_pud_folded(mm)) return _REGION3_ENTRY_EMPTY; - if (mm->context.asce_limit <= _REGION1_SIZE) + if (mm_p4d_folded(mm)) return _REGION2_ENTRY_EMPTY; return _REGION1_ENTRY_EMPTY; } diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 0e7cb0dc9c33..de05466ce50c 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -485,6 +485,24 @@ static inline int is_module_addr(void *addr) _REGION_ENTRY_PROTECT | \ _REGION_ENTRY_NOEXEC) +static inline bool mm_p4d_folded(struct mm_struct *mm) +{ + return mm->context.asce_limit <= _REGION1_SIZE; +} +#define mm_p4d_folded(mm) mm_p4d_folded(mm) + +static inline bool mm_pud_folded(struct mm_struct *mm) +{ + return mm->context.asce_limit <= _REGION2_SIZE; +} +#define mm_pud_folded(mm) mm_pud_folded(mm) + +static inline bool mm_pmd_folded(struct mm_struct *mm) +{ + return mm->context.asce_limit <= _REGION3_SIZE; +} +#define mm_pmd_folded(mm) mm_pmd_folded(mm) + static inline int mm_has_pgste(struct mm_struct *mm) { #ifdef CONFIG_PGSTE diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index 457b7ba0fbb6..b31c779cf581 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -136,7 +136,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, unsigned long address) { - if (tlb->mm->context.asce_limit <= _REGION3_SIZE) + if (mm_pmd_folded(tlb->mm)) return; pgtable_pmd_page_dtor(virt_to_page(pmd)); tlb_remove_table(tlb, pmd); @@ -152,7 +152,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, unsigned long address) { - if (tlb->mm->context.asce_limit <= _REGION1_SIZE) + if (mm_p4d_folded(tlb->mm)) return; tlb_remove_table(tlb, p4d); } @@ -167,7 +167,7 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, unsigned long address) { - if (tlb->mm->context.asce_limit <= _REGION2_SIZE) + if (mm_pud_folded(tlb->mm)) return; tlb_remove_table(tlb, pud); }