Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp996290imm; Wed, 6 Jun 2018 08:57:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISnFS2N7RNeU++/j27UT8XGjhFCmNE0t5HMPWeDPJvP3wab8tImEeI0Jwds8FcaY96rSco X-Received: by 2002:a17:902:26:: with SMTP id 35-v6mr3822695pla.276.1528300635924; Wed, 06 Jun 2018 08:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528300635; cv=none; d=google.com; s=arc-20160816; b=ZBivOqjIfPMxZXydlx7hlhPn3bDiMZlIkG60A2wBugY4X7HmPDQoFi/bIkfPQDStIG 1VBVY6fhg8ezw0UwoQQmZYpwLL/ncB4b4KfZL3g0F8TQry7p/TeGyez/9opsqjS60w7t 2d48Txq7FzTxP/kJdOGw6TibZ2fQdq4Ys1svzfzlYvbG7wvVn6c38yhJwpxAPtp4dwBX 0FbJfSEy97BtlkmxMx949u9wxqvtPiCvj7T+v0XToIcz7jzcUfSgMNDOrNGrorUy2zX7 sLbEHPpxNGTh73mbccrRFnvylhv8F2ASNP3EUyE40JX5ZtZcG1aSmdEi48669pNwXQj1 pQXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=JRhBvAS6HiDCFvVATlEQuc33/1vRK1vo9tjcpPj/3NE=; b=Qpko930UeTOvsM5V7QWgfSfNBueklUH8kvkuCEOGjQThBRoewBsI9VqzGmEuv5wVXg eM5R5mIjx6mOrsY/jGH3S6VrJPwkBW0J7DMorP84vu26W1mPoKIR9MNYKhQpo84K8DM5 VdWiJvy2cX9JyJrMsoeWQXKaVP0n/ePmzrkksROUA4agrRWVXSRS1E4rbndbw8kLAbfQ B1phk4aGQBhJvHAISucbiemZ7GPsQrGJaUBykwg/rvSTcEYxItTcEKv/z89q/8wwKJ/X FwhhLpuuO7XfoCGgTn2h1/Qoxb3VLFcMlFY5S0RAD0BZfzOVwNuba7ml6ybJZl03fLlE oU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ReJ9Ncl7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17-v6si7118474plo.534.2018.06.06.08.57.01; Wed, 06 Jun 2018 08:57:15 -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=@gmail.com header.s=20161025 header.b=ReJ9Ncl7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbeFFPzU (ORCPT + 99 others); Wed, 6 Jun 2018 11:55:20 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40537 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbeFFPzS (ORCPT ); Wed, 6 Jun 2018 11:55:18 -0400 Received: by mail-pg0-f68.google.com with SMTP id l2-v6so3217162pgc.7 for ; Wed, 06 Jun 2018 08:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=JRhBvAS6HiDCFvVATlEQuc33/1vRK1vo9tjcpPj/3NE=; b=ReJ9Ncl7H6ivH/RR5k9ILhG0LFLqfY9nmvHEY3nTam7bT5tWdbVYa7DxXSLOOtIHB2 oxTAhJiDooHoa/QCs8kclXeAJtiippu1YZguU0eSaspKfgCddJLdFf3PJMk3Tnp6x1OU egJ/5rsjHsYVXYsjCfLrMTfj2SnjDYKRlmII6qfdC9gqEHmuDytzaNydEBbXmHJILH4q pC1UgdbLinRtiR4+xMGHK/Q9dhKlxXcbG38YoktOqfxTW74A1VZzst6sN09Fg93uDmpS TU1kuDTB6LV60yKg5eWZKk4KALU/LzhAusQ3Ukkz6i0ZcCtDka0SDXoJtP3Q9tT6/Quf WPew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=JRhBvAS6HiDCFvVATlEQuc33/1vRK1vo9tjcpPj/3NE=; b=fXY626vXD84xgjXO1f1fvBLZlFH+Na5iCyVOBAqGA4xiwt3Rs189CTgOnONKj087TM 7EHhQmOKqUtoyHlFWblEaRo7bDYwlwIa+mDaVX/rUqL5fKTBUQzmbRJW77YuqvebRzwH GDgu5wsYQ2M7km5bwoceSQO0uS2WFmmyJYPByB+efNPfTmXY+MRKE6caZhkiQ9dbyNK9 BBS7E70aiuw6yfgH2G3uw2oYnON6AF/qP5rSk5JRyMt0Cnig7PwbifSDDLh5G3ZDl4fo eogTfy4kRvDcNdyF0DwO26aIyzpnkaZBiLM1tiZJAUpDoNUpo/Q0SoOax8NVnRPPeaYE cyWw== X-Gm-Message-State: APt69E1OdcSXfa2hcn/1CorYR3d6lTqH9Y1+tA7LZk1GVi5pj0P4p4a1 hOrvRFiBvJieH7epjTVFysI= X-Received: by 2002:a63:6f8a:: with SMTP id k132-v6mr3022621pgc.153.1528300517247; Wed, 06 Jun 2018 08:55:17 -0700 (PDT) Received: from [10.2.101.129] ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id z13-v6sm80251839pfe.77.2018.06.06.08.55.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 08:55:16 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] mremap: Increase LATENCY_LIMIT of mremap to reduce the number of TLB shootdowns From: Nadav Amit In-Reply-To: <20180606140255.br5ztpeqdmwfto47@techsingularity.net> Date: Wed, 6 Jun 2018 08:55:15 -0700 Cc: Andrew Morton , Dave Hansen , mhocko@kernel.org, vbabka@suse.cz, Aaron Lu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20180606140255.br5ztpeqdmwfto47@techsingularity.net> To: Mel Gorman X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mel Gorman wrote: > Commit 5d1904204c99 ("mremap: fix race between mremap() and page = cleanning") > fixed races between mremap and other operations for both file-backed = and > anonymous mappings. The file-backed was the most critical as it = allowed the > possibility that data could be changed on a physical page after = page_mkclean > returned which could trigger data loss or data integrity issues. A = customer > reported that the cost of the TLBs for anonymous regressions was = excessive > and resulting in a 30-50% drop in performance overall since this = commit > on a microbenchmark. Unfortunately I neither have access to the = test-case > nor can I describe what it does other than saying that mremap = operations > dominate heavily. >=20 > This patch increases the LATENCY_LIMIT to handle TLB flushes on a > PMD boundary instead of every 64 pages. This reduces the number of TLB > shootdowns by a factor of 8 which is not reported to completely = restore > performance but gets it within an acceptable percentage. The given = metric > here is simply described as "higher is better". >=20 > Baseline that was known good > 002: Metric: 91.05 > 004: Metric: 109.45 > 008: Metric: 73.08 > 016: Metric: 58.14 > 032: Metric: 61.09 > 064: Metric: 57.76 > 128: Metric: 55.43 >=20 > Current > 001: Metric: 54.98 > 002: Metric: 56.56 > 004: Metric: 41.22 > 008: Metric: 35.96 > 016: Metric: 36.45 > 032: Metric: 35.71 > 064: Metric: 35.73 > 128: Metric: 34.96 >=20 > With patch > 001: Metric: 61.43 > 002: Metric: 81.64 > 004: Metric: 67.92 > 008: Metric: 51.67 > 016: Metric: 50.47 > 032: Metric: 52.29 > 064: Metric: 50.01 > 128: Metric: 49.04 >=20 > So for low threads, it's not restored but for larger number of = threads, > it's closer to the "known good" baseline. The downside is that PTL = lock > hold times will be slightly higher but it's unlikely that an mremap = and > another operation will contend on the same PMD. This is the first time = I > encountered a realistic workload that was mremap intensive (thousands = of > calls per second with small ranges dominating). >=20 > Using a different mremap-intensive workload that is not representative = of > the real workload there is little difference observed outside of noise = in > the headline metrics However, the TLB shootdowns are reduced by 11% on > average and at the peak, TLB shootdowns were reduced by 21%. = Interrupts > were sampled every second while the workload ran to get those figures. > It's known that the figures will vary as the non-representative load = is > non-deterministic. >=20 > An alternative patch was posted that should have significantly reduced = the > TLB flushes but unfortunately it does not perform as well as this = version > on the customer test case. If revisited, the two patches can stack on = top > of each other. >=20 > Signed-off-by: Mel Gorman > --- > mm/mremap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/mremap.c b/mm/mremap.c > index 049470aa1e3e..b5017cb2e1e9 100644 > --- a/mm/mremap.c > +++ b/mm/mremap.c > @@ -191,7 +191,7 @@ static void move_ptes(struct vm_area_struct *vma, = pmd_t *old_pmd, > drop_rmap_locks(vma); > } >=20 > -#define LATENCY_LIMIT (64 * PAGE_SIZE) > +#define LATENCY_LIMIT (PMD_SIZE) >=20 > unsigned long move_page_tables(struct vm_area_struct *vma, > unsigned long old_addr, struct vm_area_struct *new_vma, This LATENCY_LIMIT is only used in move_page_tables() in the following manner: next =3D (new_addr + PMD_SIZE) & PMD_MASK; if (extent > next - new_addr) extent =3D next - new_addr; if (extent > LATENCY_LIMIT) extent =3D LATENCY_LIMIT; =20 If LATENCY_LIMIT is to be changed to PMD_SIZE, then IIUC the last = condition is not required, and LATENCY_LIMIT can just be removed (assuming there = is no underflow case that hides somewhere). No?