From patchwork Wed Oct 31 13:00:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schwidefsky X-Patchwork-Id: 10662623 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 59F3013BF for ; Wed, 31 Oct 2018 13:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49ABA2AD4F for ; Wed, 31 Oct 2018 13:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47B302AD6C; Wed, 31 Oct 2018 13:00:21 +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 CD3D62AD49 for ; Wed, 31 Oct 2018 13:00:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 930766B02B6; Wed, 31 Oct 2018 09:00:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 864076B02B7; Wed, 31 Oct 2018 09:00:14 -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 753ED6B02C5; Wed, 31 Oct 2018 09:00:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id 45F966B02B7 for ; Wed, 31 Oct 2018 09:00:14 -0400 (EDT) Received: by mail-ot1-f72.google.com with SMTP id x9so6105187otg.19 for ; Wed, 31 Oct 2018 06:00:14 -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=yF0JAGxfb2kHnnD5o9sfrALN8GHj+VSrHmCH2z5t4KY=; b=aj8+jG9zRRaxiIrppayzaipKknwmiqkfx7N8SFgIMldiBjzWA6uGdlGcYVaWSspvBM g2s6RfCCXnj/NFYMBB7qWqzLZPqxQbZ6VuzPxcxBT3VY/dZbl76korldAZ/Puj85/3vR dn4fS2EnJz4M1tWu1zNcngfQa7iQeRAMWw7gDDXkXSA/XTJ/7hniNgTPe1WsHOvlgvYv d8wwbvH49CKUXLVKxVbzmESe1hFNnSyPgkC5KD5dv1bP6bNFS9Ncdl7sZfCp9Jo4PPxE qvhXcXsTSNIC9toSKk76U7y4gRgx6X2AmAaAqKaBviVX2EpqOZBdoz9EkcXzTpmsrwZU wzow== 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: AGRZ1gK9rPq+BuxaMGPIUV113QbM7q1B+8OSMhfdROskY2/WCkadDs7q MPxd8PDNEFwws5V23wCVI7HLAyYSEVXHG8O09DyeZIpNcHmOieHQrvU2qNlUB6e/3TtV/SqKngh ZCEPjUmv1crRG9kAQ6U6nSD+LFhf4o87nXeGdZ1KcGjONv2OHHNfDTYYxRf/iCqVX/w== X-Received: by 2002:aca:2b13:: with SMTP id i19-v6mr1628572oik.264.1540990814049; Wed, 31 Oct 2018 06:00:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5doCXQV0ru4lSTbLsXOgFtkiADegjJIsJ4K8i771NFTVw/wFlLmIDjCtvZDCxzSmMyd8Hn1 X-Received: by 2002:aca:2b13:: with SMTP id i19-v6mr1628545oik.264.1540990813153; Wed, 31 Oct 2018 06:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540990813; cv=none; d=google.com; s=arc-20160816; b=nZC+aQX6AB8JbRyvyNMqrG/Z80Ae1fkFQnjTy4JeKR9zdmbKYNqBXgi+2f2B82FVWe 6GkWQeCbhYugV8UxY6gMuClTa7yD0ZJ5UEkFpMic8jBOcNpQXcZU+XBpwaRAOqpXgKQY yvyqo+UaUBBg/kTgT/Hl2Ntw9wPqVU63FD3YjqP9ueo5shsKJSHGI8vnRrVJMRazKwsF fuVbluGdSAki53JVjE5IKhFTM2Fatf5Efohomeoiy+7+0Y4Co8I8eWVX8Ry3EIMNpOn4 p5aHSRYm0TfOXvgmie07eiOjGZIRAdDfTJLG4/SWg2f22sxf3LzSAjfaSyJe2Rpj7zta gyAA== 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=yF0JAGxfb2kHnnD5o9sfrALN8GHj+VSrHmCH2z5t4KY=; b=FdToTKbgbTiazgmwCRtarV3WbnbQEy57Z4SIVpGby2mRlCsxytXYuP9rXO829Gez1g uL3Ja62fJ3b0r6krcr2MqkVb7Xm+OjP7+x3kWZXtLnWjnbmMepKog1TcqPicS+e2X9j8 VilsN+7eQtoF+EWztPYt6Dqi/hCKPva53oTKkS9AC7nLegCpDm6fhubUG+RH6il0Zgxj 2n/fZVlEJvDWfZRnP8rB3gO8kqjI2rphvjgKEHukll4wjag6EvAJ/3XOx72TUviMBNWQ zMWtbYJ63Yts6CybkRxw7UnDU2d1Nbbw1o7LOwYox5hSe8OVyKz9Q9dFn+NM7oXzx1O0 u1vA== 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 n32si3582442otb.32.2018.10.31.06.00.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:00:13 -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 (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9VCx5mq110152 for ; Wed, 31 Oct 2018 09:00:12 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nfbgy46a3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 09:00:12 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 13:00:09 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Wed, 31 Oct 2018 13:00:07 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9VD063O36307176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 13:00:06 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5203E11C05E; Wed, 31 Oct 2018 13:00:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D7BE11C058; Wed, 31 Oct 2018 13:00:06 +0000 (GMT) Received: from mschwideX1.boeblingen.de.ibm.com (unknown [9.152.212.164]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 31 Oct 2018 13:00:05 +0000 (GMT) From: Martin Schwidefsky To: Li Wang , Guenter Roeck , Janosch Frank , "Kirill A. Shutemov" , Heiko Carstens , linux-kernel , Linux-MM Cc: Martin Schwidefsky Subject: [PATCH 3/4] mm: add mm_pxd_folded checks to pgtable_bytes accounting functions Date: Wed, 31 Oct 2018 14:00:00 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540990801-4261-1-git-send-email-schwidefsky@de.ibm.com> References: <1540990801-4261-1-git-send-email-schwidefsky@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103113-0012-0000-0000-000002C105DD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103113-0013-0000-0000-000020F531BF Message-Id: <1540990801-4261-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-31_05:,, 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=707 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310109 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. Acked-by: Kirill A. Shutemov Signed-off-by: Martin Schwidefsky --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 1e52b8f..844a853 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1744,11 +1744,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 @@ -1768,11 +1772,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