Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3339505ioa; Tue, 26 Apr 2022 01:29:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfy1DQJE4bwt5BzbFadUeDlQsUGbtF2U+iC43AiavFhyptjGaamKFj97r8spjnliyGHuMf X-Received: by 2002:a50:d707:0:b0:425:e37d:4ef3 with SMTP id t7-20020a50d707000000b00425e37d4ef3mr11023185edi.167.1650961783160; Tue, 26 Apr 2022 01:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650961783; cv=none; d=google.com; s=arc-20160816; b=ZhYPbVXoeyGY+JEqSVovm3er/C+r+e5aqnI+zujV9ysnT4o8/nVHvZTxK6p9Ge+KE4 Pv0UUPSB2/TJj6rRw23rDEYDrvKwIp8l65AQrQ/+8LqwYVC+irubMu/tHlKlciGxlmvj xTRrS6UkXl/9vspPoYutc73BDUa3Ru1UAr8wkXUgxmOVuyl51VHe8ba8j9ATnhEmdCbB x1IXzgSPtfjwETxr8hT+r2F/6APwr09YILo62Dyf/0nNZoiulwHyAR1eJkrSQfJQQHIW B0BUaAFuCfR871NxbST2ZiRlN8Fp8O5E61P8OgHX1ekeh8X2CbIG5lgBLd+nulvXCEs+ Ag+A== 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=Xk1fRrXwMY49fkEklzghzXkAbwf3cL6niuJY5FykJaY=; b=mQTYex9+fwaWpnaKLdQTwMakoeWm50PmJDlEhkEkpuFE9DewaVInKmncFU4LEQ3GjW USlB0b22/tLpVtd/EFyWLwEtNk4KpO+aeABH1DtWooGUqv4kfyk9dEBKv/INDs0RwJEc BJTSgKh7BOgJClCi4wreiTbu5+Ml34s4rDVyZrHB4yttwc/Dpx8+Aoe/EwiUmTfbdKdr d6IDY7BJmExf8Qjva1xMTknZ5lP+ysmssP/6eqPreFQ0rph+PZQmxJCxkt/Qq7me0mgU mxC3X2baVazzY9RoShHvpXWS5TjmC27z6DBzHXC4vX8wRoYy7nTcJZneuef59JkqYt7w b6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XKpip720; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a17090655d000b006df76385df3si2628492ejp.659.2022.04.26.01.29.19; Tue, 26 Apr 2022 01:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XKpip720; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S245217AbiDZGdc (ORCPT + 99 others); Tue, 26 Apr 2022 02:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245102AbiDZGdW (ORCPT ); Tue, 26 Apr 2022 02:33:22 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED702617F for ; Mon, 25 Apr 2022 23:30:15 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id y76so1892151ybe.1 for ; Mon, 25 Apr 2022 23:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xk1fRrXwMY49fkEklzghzXkAbwf3cL6niuJY5FykJaY=; b=XKpip720WjbGzHfP5YW9gSB8hFdf4hNkRtU+Adgc2GptypWuimrKfm4d/jTk1AJN2S wvD9Q6Sle0BhWy7kUbqvV8S9J14hP2H7Xf0KqXsQ5ogF+LBDqfcEYPCdNRdqYphLhYst 22mhzSuTfN0lo3t2tx9A3sGF+U1uEyp9clr9Xx3jpUbJiTz+16DdaivMegtOh6JHgpou X1AELsmWoTmVvYVEFo3ay4KIKBVJs94KXqylK86UsUPhaTfWV1lgeshVI4fyRf3mURus SOGA0Snj1/dFaXKuZs3n2+NlRmHfLxPyes/tTiY6eQBGZM5hOAjIUScfKhZrHCgCDqiq 8mHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xk1fRrXwMY49fkEklzghzXkAbwf3cL6niuJY5FykJaY=; b=prOERVXfwZFreAtj4zwtsTZumAQievtT0IW3iwOLU1XQ5ENn/9LBbqpXwbiiDeVqnr Wr6OROL8G1nmVD/wkpnvQEIYT8ioZ8PkgoDDQuyxftIsNIwQqBU3Jw0LWZHBddKxiMGg m36o4SDc4aNIgX53pVFa0XgbhV7PjIRKbG2KZgHONXNe9NYROfpFc9aomRE63awq1Sx+ g9wkhdjZpV4kCCt6uK3bSnWYEmTwRUC4Rh1jsPD54AIy3dRydc51ZPmhsJDLMz9+jdcu UnqV1JmdCjOkwFwLjzuRLGH5sJB4/1jGeCLiMxGP5mN7LpcCd3kwG3/JlBPULh0Ri/I0 Ue2A== X-Gm-Message-State: AOAM531cy/tuo+KnCr9Bj6S2wGw89J4KeG6h4gAKBMXEfEYcjVO+4Qgo odow2vbc+6VanjisN7PYig1WhGO2fgi1pQSqzHi8mexjTnViog== X-Received: by 2002:a05:6902:1242:b0:644:c30c:cfcc with SMTP id t2-20020a056902124200b00644c30ccfccmr18900379ybu.509.1650954614961; Mon, 25 Apr 2022 23:30:14 -0700 (PDT) MIME-Version: 1.0 References: <20220420095906.27349-1-mgorman@techsingularity.net> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 25 Apr 2022 23:30:03 -0700 Message-ID: Subject: Re: [RFC PATCH 0/6] Drain remote per-cpu directly To: Mel Gorman Cc: Nicolas Saenz Julienne , Marcelo Tosatti , Vlastimil Babka , Michal Hocko , LKML , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 25, 2022 at 7:49 PM Suren Baghdasaryan wrote: > > On Wed, Apr 20, 2022 at 2:59 AM Mel Gorman wrote: > > > > This series has the same intent as Nicolas' series "mm/page_alloc: Remote > > per-cpu lists drain support" -- avoid interference of a high priority > > task due to a workqueue item draining per-cpu page lists. While many > > workloads can tolerate a brief interruption, it may be cause a real-time > > task runnning on a NOHZ_FULL CPU to miss a deadline and at minimum, > > the draining in non-deterministic. > > > > Currently an IRQ-safe local_lock protects the page allocator per-cpu lists. > > The local_lock on its own prevents migration and the IRQ disabling protects > > from corruption due to an interrupt arriving while a page allocation is > > in progress. The locking is inherently unsafe for remote access unless > > the CPU is hot-removed. > > > > This series adjusts the locking. A spin-lock is added to struct > > per_cpu_pages to protect the list contents while local_lock_irq continues > > to prevent migration and IRQ reentry. This allows a remote CPU to safely > > drain a remote per-cpu list. > > > > This series is a partial series. Follow-on work would allow the > > local_irq_save to be converted to a local_irq to avoid IRQs being > > disabled/enabled in most cases. However, there are enough corner cases > > that it deserves a series on its own separated by one kernel release and > > the priority right now is to avoid interference of high priority tasks. > > > > Patch 1 is a cosmetic patch to clarify when page->lru is storing buddy pages > > and when it is storing per-cpu pages. > > > > Patch 2 shrinks per_cpu_pages to make room for a spin lock. Strictly speaking > > this is not necessary but it avoids per_cpu_pages consuming another > > cache line. > > > > Patch 3 is a preparation patch to avoid code duplication. > > > > Patch 4 is a simple micro-optimisation that improves code flow necessary for > > a later patch to avoid code duplication. > > > > Patch 5 uses a spin_lock to protect the per_cpu_pages contents while still > > relying on local_lock to prevent migration, stabilise the pcp > > lookup and prevent IRQ reentrancy. > > > > Patch 6 remote drains per-cpu pages directly instead of using a workqueue. > > This quite possibly solves the issue I was trying to fix in > https://lore.kernel.org/all/20220225012819.1807147-1-surenb@google.com. > I will give it a try and see how it looks. My test shows sizable improvement for the worst case drain_all_pages duration. Before the change I caught cases when a drain_local_pages_wq in the workqueue was delayed by 100+ms (not even counting drain_local_pages_wq execution time itself). With this patchset the worst time I was able to record for drain_all_pages duration was 17ms. > Thanks! > > > > > include/linux/mm_types.h | 5 + > > include/linux/mmzone.h | 12 +- > > mm/page_alloc.c | 333 ++++++++++++++++++++++++--------------- > > 3 files changed, 222 insertions(+), 128 deletions(-) > > > > -- > > 2.34.1 > > > >