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=-6.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9D28DC5519F for ; Mon, 16 Nov 2020 15:05:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0930522450 for ; Mon, 16 Nov 2020 15:05:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="fC+kroDr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0930522450 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D3AB6B0071; Mon, 16 Nov 2020 10:05:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2849B6B0072; Mon, 16 Nov 2020 10:05:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 173C96B0073; Mon, 16 Nov 2020 10:05:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id DD5EA6B0071 for ; Mon, 16 Nov 2020 10:05:03 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7B436180AD80F for ; Mon, 16 Nov 2020 15:05:03 +0000 (UTC) X-FDA: 77490604086.11.care14_5605d0727329 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 181D0180F8B8B for ; Mon, 16 Nov 2020 15:05:03 +0000 (UTC) X-HE-Tag: care14_5605d0727329 X-Filterd-Recvd-Size: 5513 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Nov 2020 15:05:02 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id b16so12801109qtb.6 for ; Mon, 16 Nov 2020 07:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=peTt0Mms593LoO2PuBM0TsDE6Qx7ZUxtRHVaaA7svoQ=; b=fC+kroDrq/xQNERtX2LSop7OnuNHBHz0/y4czDoPzD7cZxnES8q9cVAs7oX6ahdnlj zXDSmm5lzULZ10/1hXLEE8ap6dkFoJ5my9w5/hYYxQWO4UpAOrE55MdPief+W6/1wryc SRLvAq5OwGepX4bsQkYtUYZRzoARKuLZHhVANG8Sx9bZ1ik0c4ah7kt5Zz1lMM0yg8ix dTMw/Bh8F2LYa7zvULStn6+kJoCinrjKjmr8KiRh5U5KM9I6d5/u5kui70NRxQojrqFQ RdCfk/0zWo3DEdCYwsH0HIxUSqo9rQsTAKY0woboCf4uFMSjilQNgTyPaJ6e3HRteFuk LTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=peTt0Mms593LoO2PuBM0TsDE6Qx7ZUxtRHVaaA7svoQ=; b=qXy7wJ+9cZhHdB38YxPwwF3SSHASxhJOw1Cbaw5qHFO/g6gtlPKCpx2Ko2n0jEHs1F J7sRupkbD69DaUyL8UkeELv2tbSmnPG79rFDb3IfaIhNKFwcR+BKDvdADSymQcTKW7d5 4mDMWWoNHQounKCPmazqMed4hYXOCHyGY4MwFThgtI3aDhmKlSob2jVBAqY0JW+GTbmv cTEGExBd0Fei1BrWUVE7H+wtRkxc/U/Vfso9wnqkHkYBkSWq2cF6zWyZv8f6DZXlL4Az N6KeVyNzMD4oYTg4W9vyRUx8Z4T1Wfl74eKcNB91cmSy007KCwRdqaOADXK9AzmWXrZK K8qA== X-Gm-Message-State: AOAM531Hm4OXP09BwWJphMilT4fX6+DvXJie+hy9By5VtjLMDfBQRszn LsFyOXOFKZ6hjefehfD8ru9/YA== X-Google-Smtp-Source: ABdhPJyyp+H0t/+lgxpeH7Lpcz4n2yK+AjYpBwtxMnJifPiMCJH5whrQtJ+kLkdq8JVXAQ3f6RXEXA== X-Received: by 2002:ac8:5b94:: with SMTP id a20mr14538722qta.223.1605539101637; Mon, 16 Nov 2020 07:05:01 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:e49]) by smtp.gmail.com with ESMTPSA id o187sm12299486qkb.120.2020.11.16.07.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 07:05:00 -0800 (PST) Date: Mon, 16 Nov 2020 10:03:09 -0500 From: Johannes Weiner To: Andrew Morton Cc: Roman Gushchin , linux-mm@kvack.org, Shakeel Butt , Michal Hocko , Christoph Lameter , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab caches with SLAB_ACCOUNT Message-ID: <20201116150309.GA924708@cmpxchg.org> References: <20201110195753.530157-1-guro@fb.com> <20201110195753.530157-2-guro@fb.com> <20201112162303.GB873621@cmpxchg.org> <20201113001926.GA2934489@carbon.dhcp.thefacebook.com> <20201112171239.4f8ef107f741c3462556731f@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201112171239.4f8ef107f741c3462556731f@linux-foundation.org> 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 Thu, Nov 12, 2020 at 05:12:39PM -0800, Andrew Morton wrote: > On Thu, 12 Nov 2020 16:19:26 -0800 Roman Gushchin wrote: > > > >From 8b28d91475d54c552e503e66f169e1e00475c856 Mon Sep 17 00:00:00 2001 > > From: Roman Gushchin > > Date: Wed, 16 Sep 2020 15:43:48 -0700 > > Subject: [PATCH v2 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab > > caches with SLAB_ACCOUNT > > > > In general it's unknown in advance if a slab page will contain > > accounted objects or not. In order to avoid memory waste, an > > obj_cgroup vector is allocated dynamically when a need to account > > of a new object arises. Such approach is memory efficient, but > > requires an expensive cmpxchg() to set up the memcg/objcgs pointer, > > because an allocation can race with a different allocation on another > > cpu. > > > > But in some common cases it's known for sure that a slab page will > > contain accounted objects: if the page belongs to a slab cache with a > > SLAB_ACCOUNT flag set. It includes such popular objects like > > vm_area_struct, anon_vma, task_struct, etc. > > > > In such cases we can pre-allocate the objcgs vector and simple assign > > it to the page without any atomic operations, because at this early > > stage the page is not visible to anyone else. > > > > v2: inline set_page_objcgs() and add some comments, by Johannes > > Had me confused! I was looking for the inlined function > set_page_objcgs(). I think "open-code" is a better term here than > "inline". > > Here's the -fix: > > From: Roman Gushchin > Subject: mm-memcg-slab-pre-allocate-obj_cgroups-for-slab-caches-with-slab_account-v2 > > open-code set_page_objcgs() and add some comments, by Johannes > > Link: https://lkml.kernel.org/r/20201113001926.GA2934489@carbon.dhcp.thefacebook.com > Signed-off-by: Roman Gushchin > Cc: Christoph Lameter > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Shakeel Butt > Signed-off-by: Andrew Morton Thanks! For the combined patch: Acked-by: Johannes Weiner