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=-11.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 7FE13C433DF for ; Mon, 22 Jun 2020 17:29:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 456E22075A for ; Mon, 22 Jun 2020 17:29:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f8q5Ux28" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 456E22075A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5A756B0002; Mon, 22 Jun 2020 13:29:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0AE96B000D; Mon, 22 Jun 2020 13:29:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1F7D6B0010; Mon, 22 Jun 2020 13:29:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id A589F6B0002 for ; Mon, 22 Jun 2020 13:29:44 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 488EA17D07E for ; Mon, 22 Jun 2020 17:29:44 +0000 (UTC) X-FDA: 76957535088.04.mass66_4105eeb26e34 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id C59288517912 for ; Mon, 22 Jun 2020 17:29:42 +0000 (UTC) X-HE-Tag: mass66_4105eeb26e34 X-Filterd-Recvd-Size: 4083 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Mon, 22 Jun 2020 17:29:42 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id y18so1490746lfh.11 for ; Mon, 22 Jun 2020 10:29:42 -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=OANw2HePj9Aqy4TDtb05tpT/a2lkwTwt5qwm1TtUltk=; b=f8q5Ux28j651L7cU7a9F3GxkuERNMlXyOG1vAbcoHRt7bY5wP8d4AnBs7q4KZJ1TVk Lq3oooFQPTad5cCt5EHm6dWnFkgakBdW/jNKUEDjtjTv8FUnkH8TES79xLkytIU3Q/DQ EEr7A4ZQWsOShJWcjqg1YBcskJnDjIA+ry7q/81HShry3PyWdmyY7TOX1YAgSPDagW17 sziYJ8ZQ/5fZjxxCU5mmpXGvNKrPS/5Cn8GnNCe56CfqWQP/zSRxYBvQKrrcw/xOJKhk GjF/nhkuc7lWn1wcbdUnI0coeMxCOoiP7+0ENJYLkumKN15p4e0j9sgFDqj7JzqUPKXn c0Vw== 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=OANw2HePj9Aqy4TDtb05tpT/a2lkwTwt5qwm1TtUltk=; b=goTNnksKk8Ild+BnI5qXzO6BuJ/EXkEXctYCU7arE/fijBr9VUIjerngOBtGHkFslv /gpOhGi1wcz97D0IdluXgR1rk+lAGFPGqpTsAesk0KpfP381hsmAt5qmK/lWPHsjoF5X nkzlUxsckrsCqcOQQNT8kVX0oMGkU2WEl7xXFM/Il2bHCCgpqh6TssEPmGzaY3bGmZC7 e3L1RIbjNTXXkOB3eregJnaqvFDN+FSmzoQyLoT5BKCqNxFfjpE8/9Y1rBaYCXvil7r+ vVjUb2Frw+o7FtyU0cYqVyI4axjTAdpYuFnBbVOVgXJ6vEjChD1BeC5wTYWR9Jv3nwl6 bkkg== X-Gm-Message-State: AOAM533kwfpL3iQ/WC/R+LUGSr5N5p+Rn7zGjRISqa8nk364xyxbhSv+ SB1udWkVzv85R7AFkuBr1/T52hcLGlAicZqR//Q6fw== X-Google-Smtp-Source: ABdhPJyAxkindXp2Sqxkfa1Otdo2vEKuaePNwSrArVAX4r9Ix5aY7qleOLvfVgUk4SFnDYX29zZnY6YysN+7N60B4R4= X-Received: by 2002:a05:6512:482:: with SMTP id v2mr10277697lfq.3.1592846980702; Mon, 22 Jun 2020 10:29:40 -0700 (PDT) MIME-Version: 1.0 References: <20200608230654.828134-1-guro@fb.com> <20200608230654.828134-14-guro@fb.com> In-Reply-To: <20200608230654.828134-14-guro@fb.com> From: Shakeel Butt Date: Mon, 22 Jun 2020 10:29:29 -0700 Message-ID: Subject: Re: [PATCH v6 13/19] mm: memcg/slab: simplify memcg cache creation To: Roman Gushchin Cc: Andrew Morton , Christoph Lameter , Johannes Weiner , Michal Hocko , Linux MM , Vlastimil Babka , Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: C59288517912 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: On Mon, Jun 8, 2020 at 4:07 PM Roman Gushchin wrote: > > Because the number of non-root kmem_caches doesn't depend on the > number of memory cgroups anymore and is generally not very big, > there is no more need for a dedicated workqueue. > > Also, as there is no more need to pass any arguments to the > memcg_create_kmem_cache() except the root kmem_cache, it's > possible to just embed the work structure into the kmem_cache > and avoid the dynamic allocation of the work structure. > > This will also simplify the synchronization: for each root kmem_cache > there is only one work. So there will be no more concurrent attempts > to create a non-root kmem_cache for a root kmem_cache: the second and > all following attempts to queue the work will fail. > > > On the kmem_cache destruction path there is no more need to call the > expensive flush_workqueue() and wait for all pending works to be > finished. Instead, cancel_work_sync() can be used to cancel/wait for > only one work. > > Signed-off-by: Roman Gushchin > Reviewed-by: Vlastimil Babka Why not pre-allocate the non-root kmem_cache at the kmem_cache creation time? No need for work_struct, queue_work() or cancel_work_sync() at all.