Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3714598ybl; Tue, 20 Aug 2019 00:53:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBJB7XG8tEmZBKKsJ5tkLLMysIc/ciiqJQSIOtXwVy2KJ4PknB2Ayfk+NI+811UdBperA0 X-Received: by 2002:a17:902:306:: with SMTP id 6mr26872488pld.86.1566287583126; Tue, 20 Aug 2019 00:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566287583; cv=none; d=google.com; s=arc-20160816; b=cn5lw+wkVbxefWYBGp8hWd2N0epKlNWvtVwucYB2q8R2sUt7JgjBSMz34tcbUQF6OP NE9dA0MoIehddH0d4czKUIcDfron9AIzRiBkFNZEccjwZCqZPWIPyGvXOZfYHAhB/Ndi 1qCLeGf7USFHruSxMw6CK5Lni08gi2LahkNR3fgue1KHnOrj8a3uw4DZhQZmZrI0YDqm fzDF9LRnMz7yQ5Ik7/CsKJ8iGDGyMvYAw28/Mi3Q8YBrvDJYp4GLi/vFP4vTA8YT62Qn gT4D/3WqcP2nZEdqlQEc+M9SSJqRi7yoqfj/sNnX420YHW8owI0zIZLgA6ZzL3wIV9JZ 3FKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature; bh=NdN+ZDMV6cVKAsWdTWSaLrD9VOB5N6fSXCo/EOCkxFQ=; b=JOhqQirZ4RbLXdc+wxIM0PAJeryCdRL9OYI9N6IM1LE+8Nc2n0ELSyMDLOHXG9kiO+ Y+gWqpED0g9WlE8SRo9sLx2fZIgsFQd9VOgtFDCJl4s2poTEE9jwbZty3gSzLUlgr6rF k0/ly5mm72CQ0SOa3TbtZ98ajFKJlsaheqWtUOCzag5CAbKnJYplMDgSJ3C7vE1OWeu9 A7jXMkFFDJoi4+jnQbEUNo1xDAFoXQSbXDov1NOTJNmclG1zxQjoQH2HU75Vt1oK7hMs V3ovRoDYOdGOORm0jBY1IQZ8EeU357O37awEX0+DkaMxMnnhpfw26fGpDQOTe2s3Rr/l 3+Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=YeDYM8WA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si12802564pfq.118.2019.08.20.00.52.47; Tue, 20 Aug 2019 00:53:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=YeDYM8WA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729342AbfHTHvh (ORCPT + 99 others); Tue, 20 Aug 2019 03:51:37 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:40576 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729181AbfHTHvg (ORCPT ); Tue, 20 Aug 2019 03:51:36 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x7K7nE1e029410 for ; Tue, 20 Aug 2019 00:51:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=NdN+ZDMV6cVKAsWdTWSaLrD9VOB5N6fSXCo/EOCkxFQ=; b=YeDYM8WAG3No/5UtcvOxnM31qeYGu3zCPpWpcFoxyjehF3LmYVMqebhG8fBuWF3t+N24 wV3pAeo8mct0Zp1R2KTVymmuZ7jTyBwj+LGthGU8KOap4QrVAIMgVKJbW9A5xDpjOTWh vQNnPEuJqRM+pdqksRK/jcwIK0PREaU9Pv4= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0089730.ppops.net with ESMTP id 2ug5t3sc6v-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Aug 2019 00:51:35 -0700 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Tue, 20 Aug 2019 00:51:33 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 0559462E2CCB; Tue, 20 Aug 2019 00:51:31 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , CC: , Song Liu , , Joerg Roedel , Thomas Gleixner , Dave Hansen , Andy Lutomirski , Peter Zijlstra Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH] x86/mm/pti: in pti_clone_pgtable() don't increase addr by PUD_SIZE Date: Tue, 20 Aug 2019 00:51:28 -0700 Message-ID: <20190820075128.2912224-1-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-20_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=591 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908200083 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pti_clone_pgtable() increases addr by PUD_SIZE for pud_none(*pud) case. This is not accurate because addr may not be PUD_SIZE aligned. In our x86_64 kernel, pti_clone_pgtable() fails to clone 7 PMDs because of this issuse, including PMD for the irq entry table. For a memcache like workload, this introduces about 4.5x more iTLB-load and about 2.5x more iTLB-load-misses on a Skylake CPU. This patch fixes this issue by adding PMD_SIZE to addr for pud_none() case. Cc: stable@vger.kernel.org # v4.19+ Fixes: 16a3fe634f6a ("x86/mm/pti: Clone kernel-image on PTE level for 32 bit") Signed-off-by: Song Liu Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra --- arch/x86/mm/pti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index b196524759ec..5a67c3015f59 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -330,7 +330,7 @@ pti_clone_pgtable(unsigned long start, unsigned long end, pud = pud_offset(p4d, addr); if (pud_none(*pud)) { - addr += PUD_SIZE; + addr += PMD_SIZE; continue; } -- 2.17.1