From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 583D0C43467 for ; Fri, 18 Sep 2020 19:48:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EBCA822208 for ; Fri, 18 Sep 2020 19:48:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L06jfMN2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBCA822208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19BA7900007; Fri, 18 Sep 2020 15:48:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 058D2900004; Fri, 18 Sep 2020 15:48:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3BC7900007; Fri, 18 Sep 2020 15:48:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id CD367900004 for ; Fri, 18 Sep 2020 15:48:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 930BF362C for ; Fri, 18 Sep 2020 19:48:43 +0000 (UTC) X-FDA: 77277219726.04.love95_150018b2712d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 70254800CCEE for ; Fri, 18 Sep 2020 19:48:43 +0000 (UTC) X-HE-Tag: love95_150018b2712d X-Filterd-Recvd-Size: 6008 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 19:48:42 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id a22so5983425ljp.13 for ; Fri, 18 Sep 2020 12:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SzvHH1kSKdJ2ziBgd9Jq8Z/nxeBRoANgHFle/0iuLew=; b=L06jfMN2PzbFEpKONJ57B5VlRj0rlQ0Zbw9IIWkpz1wKb8dQNExEe1OJMnfZHUCnko xX0nkCOl2aW4CdKV33nWLFKXSYE/xp0VPkqTgtkQdCwM/zJW72gYCjseA32MZawSOqBR asl+Iv2Nl/CSx7Hme52926esMeA3s2paJYuO0Doh3AZHAz4v/yq/wYUK9iLM4cZXU5xf Wp/Ts/6WBrsURw/Gr5AyZLA2x9hfSEOCutnjyFw9WqhtybeVfiXorWGBStNLRcH2oSqq aUcADxo/mRjYcLU7QDBOLqIDgnzdH/bAuyAkiM4ITemEsvaoKRQEb781x/xaU8/aM6Gb FYCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SzvHH1kSKdJ2ziBgd9Jq8Z/nxeBRoANgHFle/0iuLew=; b=ScFweU1w0N6yvplJWx+qYuK6v3FjA5Idl0B+VkRH/fwB16Re781JFjcd4JEPFO5CL5 qe+9sUMSqEey84sDbxK6A0IA7RgGBm3LYucHpNwI/NQ3ZVbxt4myRpBwy5cvm0XszbRR 53VQHcMJYINZYkPvBUe+ri5Kloc64YXfHfxpu311uge9Dv8VjhW5KjUB6FQlULxj8eWG 7ZDB0Ae7q6Pa6eRkPxezsFLSWdTgeLDo5a2LFp+gUplyRChaIa6VvuqWW78MzcFD4Qoi 0msl1SunT4b74UzU+arW9Oy0RoHwxEG+7s4RiIrXhaICD7LzPWBlK3k444OQoT96fWo+ 91bQ== X-Gm-Message-State: AOAM533gwWn7sjl+/dOQ+9y4+TGFDf/vIREoTVOJr+PKQ1PcepPMRE4S pVBhVwIJdCWzLfdiMMLmU/s= X-Google-Smtp-Source: ABdhPJzK/m1EMHaCbJdkbPMwOFhH52Qvuz4FPNXfeee2GFnRfrriSXfCcozLep37DAqr2fWTcDnZSQ== X-Received: by 2002:a2e:6f1c:: with SMTP id k28mr11293487ljc.297.1600458521547; Fri, 18 Sep 2020 12:48:41 -0700 (PDT) Received: from pc638.lan (h5ef52e31.seluork.dyn.perspektivbredband.net. [94.245.46.49]) by smtp.gmail.com with ESMTPSA id a17sm766769lfd.148.2020.09.18.12.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 12:48:41 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: LKML , RCU , linux-mm@kvack.org, Andrew Morton , "Paul E . McKenney" Cc: Peter Zijlstra , Michal Hocko , Vlastimil Babka , Thomas Gleixner , "Theodore Y . Ts'o" , Joel Fernandes , Sebastian Andrzej Siewior , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 4/4] rcu/tree: Use schedule_delayed_work() instead of WQ_HIGHPRI queue Date: Fri, 18 Sep 2020 21:48:17 +0200 Message-Id: <20200918194817.48921-5-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200918194817.48921-1-urezki@gmail.com> References: <20200918194817.48921-1-urezki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Recently the separate worker thread has been introduced to maintain the local page cache from the regular kernel context, instead of kvfree_rcu() contexts. That was done because a caller of the k[v]free_rcu() can be any context type what is a problem from the allocation point of view. >From the other hand, the lock-less way of obtaining a page has been introduced and directly injected to the k[v]free_rcu() path. Therefore it is not important anymore to use a high priority "wq" for the external job that used to fill a page cache ASAP when it was empty. Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index d51209343029..f2b4215631f7 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3100,7 +3100,7 @@ struct kfree_rcu_cpu { * lockless an access has to be protected by the * per-cpu lock. */ - struct work_struct page_cache_work; + struct delayed_work page_cache_work; atomic_t work_in_progress; struct llist_head bkvcache; int nr_bkv_objs; @@ -3354,7 +3354,7 @@ static void fill_page_cache_func(struct work_struct= *work) struct kvfree_rcu_bulk_data *bnode; struct kfree_rcu_cpu *krcp =3D container_of(work, struct kfree_rcu_cpu, - page_cache_work); + page_cache_work.work); unsigned long flags; bool pushed; int i; @@ -3440,7 +3440,6 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_cal= lback_t func) { unsigned long flags; struct kfree_rcu_cpu *krcp; - bool irq_disabled =3D irqs_disabled(); bool success; void *ptr; =20 @@ -3473,9 +3472,9 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_cal= lback_t func) =20 success =3D kvfree_call_rcu_add_ptr_to_bulk(krcp, ptr); if (!success) { - // TODO: schedule the work from the hrtimer. - if (!irq_disabled && !atomic_xchg(&krcp->work_in_progress, 1)) - queue_work(system_highpri_wq, &krcp->page_cache_work); + // Use delayed work, so we do not deadlock with rq->lock. + if (!atomic_xchg(&krcp->work_in_progress, 1)) + schedule_delayed_work(&krcp->page_cache_work, 1); =20 if (head =3D=3D NULL) // Inline if kvfree_rcu(one_arg) call. @@ -4475,7 +4474,7 @@ static void __init kfree_rcu_batch_init(void) } =20 INIT_DELAYED_WORK(&krcp->monitor_work, kfree_rcu_monitor); - INIT_WORK(&krcp->page_cache_work, fill_page_cache_func); + INIT_DELAYED_WORK(&krcp->page_cache_work, fill_page_cache_func); krcp->initialized =3D true; } if (register_shrinker(&kfree_rcu_shrinker)) --=20 2.20.1