Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3285742ioa; Mon, 25 Apr 2022 23:59:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiPFvxAebURZrPbypolaNoStYEN+M2eXGtYsLXhTUGdfvQ/buTYP3DYEquEpubazgnEK5n X-Received: by 2002:a17:902:ee8d:b0:15c:f1c1:c520 with SMTP id a13-20020a170902ee8d00b0015cf1c1c520mr14021628pld.122.1650956352242; Mon, 25 Apr 2022 23:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650956352; cv=none; d=google.com; s=arc-20160816; b=JXDTdmqxEJ/te8cfVCFNUxraYCOyU9/1XSHS0ZDijoTfy/Cl+UYzTmzZz6bUS7cooq xCf4IU9Um5dgkMyLF5VB4DRDpWv4dlxC4zz8cjHWdvBLP4dMPZlp24sR4dn970FD8rGr 4z+fyyprgLsgjyuhlITsUat3CUIdTqTDpVSZZ1XJFhYphpgLuVXMuCYiICUXA06WXcoU JqpdyQ8hW/h4d12hp3HT0wKaS1V0eS+C0NgvlvzdSg7EOIsmJJ0YMNTfeypgyKKZf+2s rGFoE7TP3ND8qf1eBf+MSCvVvr2eOErwkn8NT+VcWh3NQ9XDNQ9LQIbyzBMUO+W+elxA E8NQ== 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=HGAx5TP6E+vFvjaPxhYu9IBA2KbCco9Opl8nE6JlHZY=; b=PDuhE/TIAATB6WGWLUPHi0mxhIOsMjLX++92FvkWHNWAUfyJk2lfJ98KiX8RabOdOq pHCD2iPH9UNGVWvXM53wRTu6IFgg7/CFHt4zoLXwj/XqHBwnCQtSsoCdJn6+nVjU0tHy 5Tmg73vBbeKPcLMG5xbddVCrRT37dKa/14XcYJZaJ8EnhKEPR/Idva1HtGEhfQXTQwRL 5F/hcBHMympcWrtseOqTaDhVcxOJHQ97hdmmXVnZPbqNTHZ11VcCR8kWA8kyIWG3lTN3 LRuFJXVaP/IBpWEpDLdvZeVUSp9PyF68AWojHfu+6AwqdslGJaRESZFyY67t4tfnSpWP ykpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TveONqNN; 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 x38-20020a634866000000b0039ef5074716si18551668pgk.609.2022.04.25.23.58.57; Mon, 25 Apr 2022 23:59:12 -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=TveONqNN; 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 S239051AbiDZCxH (ORCPT + 99 others); Mon, 25 Apr 2022 22:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233692AbiDZCxD (ORCPT ); Mon, 25 Apr 2022 22:53:03 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 844F5222BF for ; Mon, 25 Apr 2022 19:49:57 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id b15so16652993pfm.5 for ; Mon, 25 Apr 2022 19:49:57 -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=HGAx5TP6E+vFvjaPxhYu9IBA2KbCco9Opl8nE6JlHZY=; b=TveONqNNTAMKRK3L5GedChuTwratL2NBA5QmxDHEPJFdUx05XPxL7uzHbRQY1k0VP+ QGH4vuhM4l6pRcU6c0G34VDTbDUmPHxvv/2QcICPqvaF2aOfkmv5iDhxDdpNFG2PzDzj pVqxylha350zoMW4sh2LSwIKCi5PJEAchJAFFeCM5Acuy2sM+GxRmKsNJmNPFojYgmX1 Tq/Bm1NlqR15AOfXiapXAZ9YImmAVAuDwPA54qd2TKhq011xasmBS0UWXvJ2iYsjQXZ0 elsIdKj+CrA5a+ZyziFasVwk+CJcf0z/2JppV5lGCAXx4HLyAoOxvDhbhfY9cGW42Y/S qEvw== 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=HGAx5TP6E+vFvjaPxhYu9IBA2KbCco9Opl8nE6JlHZY=; b=gZZ2amL2Z62JSS2p6JUHw58SC3Wc3ob3B9d08brZTzQP/s68ETRAL8F0zdDGrUns3U ChWMIBbviHlcjs6epzMVsmEqi7S8XqW8p7tA7bn5D6NKjl202ySNqs8surEXQxcmeCni BNV0e/BsRq0C6k+P0smjFWi3AK4O/ARuWdyJOdGSGO+Laf+VIVaVu+J/1dRtgiZwLa86 d02B5i0aYZPRQL5CXmPZnju3cliSw7ghEyAhkahN+5Z9cwxJm44TvCbNe5PGasTWZ6M4 2sSM8DdF+qovYX3kqWQ4U6ixitfGp8wq5RPhVI8iB1ssF2fk/LtwDXzA8x2toKZzTN6M C/+w== X-Gm-Message-State: AOAM532sTswkmGKkaLCdCNI3A6LlVZthhpUVmaoP4gYWiNKeTXAeG9Gh BBTfFf9J8J3iBP34JY8EACcRP0+Qz0VMobMe6Tp9MsIc7N8RJg== X-Received: by 2002:a63:89c7:0:b0:3ab:1f12:f807 with SMTP id v190-20020a6389c7000000b003ab1f12f807mr9017915pgd.180.1650941396751; Mon, 25 Apr 2022 19:49:56 -0700 (PDT) MIME-Version: 1.0 References: <20220420095906.27349-1-mgorman@techsingularity.net> In-Reply-To: <20220420095906.27349-1-mgorman@techsingularity.net> From: Suren Baghdasaryan Date: Mon, 25 Apr 2022 19:49:46 -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 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. 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 > >