Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp896595pxk; Thu, 1 Oct 2020 17:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgqgS1wYkgoYMcwW4fG00129Noc7lyxEIRtdTIdDVXbWiAsJhF9yIKOErX5GqNkZnar3l1 X-Received: by 2002:aa7:d30f:: with SMTP id p15mr7862574edq.256.1601597594301; Thu, 01 Oct 2020 17:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601597594; cv=none; d=google.com; s=arc-20160816; b=CEEYVvgHYHjgmWpOh29XR5FahaIuLXP5GOcB9v8YVO6Fth/oHiLOEVitCgiqHYoETu 51tCwK/9/IBAvfxcYeiyKqQlaw+mTB6QcQwJhxaiJEZzMqbztDmh8CQPfc76ElqfyMhe bUuYRXwRF3SuwW9/adVnDT5g5xxzFq3wpwjz6vAz79kUGKsxDMIGU5X9+Uf2aX/cRax9 HaO/j/eEXhrM4V5+7tVbqXsgsR+1D5sKSoP9cZM2hkVKqEUactHdWY5TMQ152KnFa7TS NpYAKQrCs3LaGiFDKPFOGcCXsymRDYQdgFWPqFPzGhGNacemG3Gb4JJP9/yld6UtbDxI R2tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SKmdoWvcoH054ieUmUn071qqw8A/m5uf6wtD7bMmYko=; b=MfoeAzQo4a+L9CzDGcvdy3IP74otzE7VQf4snjttRNl6FSUw1rx/3urDGc7Cs4sd6I o6iXR6zfOgq3pjduRPNhEPaWto8Kwth6RGSL8dBCUjKLGdFkf/tCOdvjmmdBccJYGpik EeT2mYLAucgTa+fcTa4z3kR0JHC4QKzn6yYI3AuXYyd2jWPm9GKOcIGLv4MxwkRsVGBo vtumSIFlFzimWaH/SaFcz5uvc9chBGsmsZVRtqCnLFiHkyCgztEH6EZy9z0OVaZgECA4 /2lGovDIhyLw3fG7uWKeQk+UeOTn+jgHLcA1V78ftkLT8uAj6u6VPI8MBFLrYNqEh7my JU8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=X+sw1RIw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si2690519edl.58.2020.10.01.17.12.51; Thu, 01 Oct 2020 17:13:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=X+sw1RIw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733311AbgJBAJQ (ORCPT + 99 others); Thu, 1 Oct 2020 20:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733300AbgJBAJP (ORCPT ); Thu, 1 Oct 2020 20:09:15 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 228FAC0613E2 for ; Thu, 1 Oct 2020 17:09:15 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id f15so204614ilj.2 for ; Thu, 01 Oct 2020 17:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SKmdoWvcoH054ieUmUn071qqw8A/m5uf6wtD7bMmYko=; b=X+sw1RIw3DPYL39kYpPkOfnoG49QnA+1BLDx3z5vyVL5igSZLErLIR2DlIwC0mC4nI 8R+VEgEhd4ovTkGh8wczWav2bau0zRc84DRMlxb2n0Dm/5mv4RcbhMCdA1cRtWpGAnve aj6063apIjx14YrF/V9Jz86YXUA56vWci8btoM2LfzJkubEywRNQqUQUWDL4WNfIMIwn sS5sfcDDaAy/Bz0nXdTYQONveOqAnqDOSHcGOz73kyHn0TmQ4P2fNMr0tP+zKZI/VODd TIm/1Vp7NnxwDp+ZfEJ5xZyU7hnlvTANmfr9nYlYYBP4xM3bQtwb+v+fq6QpDx0EJTRR DCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SKmdoWvcoH054ieUmUn071qqw8A/m5uf6wtD7bMmYko=; b=QkJNdHGyz09r/1Y7KEFhfoy+F1iRu6aA1uU6myR+0cUtqUqS88483s6sWKsQe7mfmF Ifp0BE+gH9T59BhAc+qNBRc5QFLYHqrIQ7lYjWlEtBrIRmYWIn9UptqdsrjSESuSts+d IMR1k8Hx1oCf8cr8b/7BYZ5+UI/sO92CvascxIPh4PC0omNxxAfN0ejVxjY8zlcUoS18 NUzvvcicxANoJnYZsWm1dKU/FamUhn/gJxuanIFYgouAX2Cb0KbwD4O+AwEu5LC/wwQl 3mtIHnj28Ebhpkt7ZdAwJmYfgVeMSQuGGRBtju5uMurioce7nL2QpVZ6bhgYnVEDKe3l NuCA== X-Gm-Message-State: AOAM532zsD9RneV9Sfayu7+6GGCjpo9DqQzgTMTF8/7kad/5GbKo1w4D Jlx3wJ4SN8Wc8q0+igbotekqUcLE8EQlmJnOU70OSw== X-Received: by 2002:a92:ba4d:: with SMTP id o74mr4690236ili.205.1601597354132; Thu, 01 Oct 2020 17:09:14 -0700 (PDT) MIME-Version: 1.0 References: <20200930222130.4175584-1-kaleshsingh@google.com> <20200930223207.5xepuvu6wr6xw5bb@black.fi.intel.com> <20201001122706.jp2zr23a43hfomyg@black.fi.intel.com> In-Reply-To: From: Lokesh Gidra Date: Thu, 1 Oct 2020 17:09:02 -0700 Message-ID: Subject: Re: [PATCH 0/5] Speed up mremap on large regions To: Kalesh Singh , "Kirill A. Shutemov" Cc: Suren Baghdasaryan , Minchan Kim , Joel Fernandes , "Cc: Android Kernel" , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "the arch/x86 maintainers" , "H. Peter Anvin" , Andrew Morton , Shuah Khan , "Aneesh Kumar K.V" , Kees Cook , Peter Zijlstra , Sami Tolvanen , Masahiro Yamada , Arnd Bergmann , Frederic Weisbecker , Krzysztof Kozlowski , Hassan Naveed , Christian Brauner , Mark Rutland , Mike Rapoport , Gavin Shan , Zhenyu Ye , Jia He , John Hubbard , William Kucharski , Sandipan Das , Ralph Campbell , Mina Almasry , Ram Pai , Dave Hansen , Kamalesh Babulal , Masami Hiramatsu , Brian Geffon , SeongJae Park , linux-kernel , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , "open list:MEMORY MANAGEMENT" , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 1, 2020 at 9:00 AM Kalesh Singh wrote: > > On Thu, Oct 1, 2020 at 8:27 AM Kirill A. Shutemov > wrote: > > > > On Wed, Sep 30, 2020 at 03:42:17PM -0700, Lokesh Gidra wrote: > > > On Wed, Sep 30, 2020 at 3:32 PM Kirill A. Shutemov > > > wrote: > > > > > > > > On Wed, Sep 30, 2020 at 10:21:17PM +0000, Kalesh Singh wrote: > > > > > mremap time can be optimized by moving entries at the PMD/PUD level if > > > > > the source and destination addresses are PMD/PUD-aligned and > > > > > PMD/PUD-sized. Enable moving at the PMD and PUD levels on arm64 and > > > > > x86. Other architectures where this type of move is supported and known to > > > > > be safe can also opt-in to these optimizations by enabling HAVE_MOVE_PMD > > > > > and HAVE_MOVE_PUD. > > > > > > > > > > Observed Performance Improvements for remapping a PUD-aligned 1GB-sized > > > > > region on x86 and arm64: > > > > > > > > > > - HAVE_MOVE_PMD is already enabled on x86 : N/A > > > > > - Enabling HAVE_MOVE_PUD on x86 : ~13x speed up > > > > > > > > > > - Enabling HAVE_MOVE_PMD on arm64 : ~ 8x speed up > > > > > - Enabling HAVE_MOVE_PUD on arm64 : ~19x speed up > > > > > > > > > > Altogether, HAVE_MOVE_PMD and HAVE_MOVE_PUD > > > > > give a total of ~150x speed up on arm64. > > > > > > > > Is there a *real* workload that benefit from HAVE_MOVE_PUD? > > > > > > > We have a Java garbage collector under development which requires > > > moving physical pages of multi-gigabyte heap using mremap. During this > > > move, the application threads have to be paused for correctness. It is > > > critical to keep this pause as short as possible to avoid jitters > > > during user interaction. This is where HAVE_MOVE_PUD will greatly > > > help. > > > > Any chance to quantify the effect of mremap() with and without > > HAVE_MOVE_PUD? > > > > I doubt it's a major contributor to the GC pause. I expect you need to > > move tens of gigs to get sizable effect. And if your GC routinely moves > > tens of gigs, maybe problem somewhere else? > > > > I'm asking for numbers, because increase in complexity comes with cost. > > If it doesn't provide an substantial benefit to a real workload > > maintaining the code forever doesn't make sense. > mremap is indeed the biggest contributor to the GC pause. It has to take place in what is typically known as a 'stop-the-world' pause, wherein all application threads are paused. During this pause the GC thread flips the GC roots (threads' stacks, globals etc.), and then resumes threads along with concurrent compaction of the heap.This GC-root flip differs depending on which compaction algorithm is being used. In our case it involves updating object references in threads' stacks and remapping java heap to a different location. The threads' stacks can be handled in parallel with the mremap. Therefore, the dominant factor is indeed the cost of mremap. From patches 2 and 4, it is clear that remapping 1GB without this optimization will take ~9ms on arm64. Although this mremap has to happen only once every GC cycle, and the typical size is also not going to be more than a GB or 2, pausing application threads for ~9ms is guaranteed to cause jitters. OTOH, with this optimization, mremap is reduced to ~60us, which is a totally acceptable pause time. Unfortunately, implementation of the new GC algorithm hasn't yet reached the point where I can quantify the effect of this optimization. But I can confirm that without this optimization the new GC will not be approved. > Lokesh on this thread would be better able to answer this. I'll let > him weigh in here. > Thanks, Kalesh > > > > -- > > Kirill A. Shutemov > > > > -- > > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > >