Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4300390pxb; Tue, 10 Nov 2020 12:52:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyua2jAi1WcTfVsPweIcqe950iALZptWosGQXJwscqbsonkrwvi0M08vdHhFHf6pefi9BHD X-Received: by 2002:a05:6402:17ad:: with SMTP id j13mr1298222edy.347.1605041564345; Tue, 10 Nov 2020 12:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605041564; cv=none; d=google.com; s=arc-20160816; b=cMGmwyxFEOKBESXqIMR0mWNlt0H2/LlcjnysM34HAs05dzgydXhdkBfWkhQFLqLiNM FVL0SZBlUTVwlycIPmdKVlSIMtOreFFOFLWPaU9xhTnwti9HufVffSI5AnTRvxScNf0W a06pE3x9+GygzLtStKlTXjoZGxmp8OrXwp1uhuZbccQPejLivEzc4sRToa3MOTMH83IL ejYaQD3f9zuQWgfW7mB6SPZnzhVuAeQ9/VjwGfRtAOEo3uOebM7ze4VW5q3Eagu+LPAu sJ9+T7l5iVjMDm/2uDLmYwNCxNIMQcHkfgILnUHOKYIdEzdam/Kd2DuZaV5xHiGGRSjJ ZnAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Ib9+XiOFRk34nplS6Jt6qruTYL5Qwd5ld1YLFvpONk4=; b=DNFRUu/tWFC795hrqhKpulXynHTDtmLehFO53nQPGayuuAq7Wmj4HZPdcAAcI8Yk1Y QYHJvXcdcHPTdnRTpYNbqRiF8RDL0m4ZVdAvzGd5AsO4eQFH2qTSeb34DUzn6356amis 3i5vUnrlhkfaxjXzxzjgE4tgqwNU44hbuX3j+KjkEFoBoNN+dhGfbA6eJpe3suHsrFg1 vSfKhAEVslk2E8mdFyiwj5CrNhVPZe/Xv44f5R5wecDaYVgQM1HErqq8qckIGUxncAqh tgNi7pLkbZcNBL27euHvN4aRX4D5AOP0lj2iBE+CXpnAMm04RJ1myHjMpVVuXpMLBGdE SOCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AVcBjBeb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si9253236eje.443.2020.11.10.12.51.55; Tue, 10 Nov 2020 12:52:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AVcBjBeb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731657AbgKJUuN (ORCPT + 99 others); Tue, 10 Nov 2020 15:50:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:57940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgKJUuM (ORCPT ); Tue, 10 Nov 2020 15:50:12 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8115620665; Tue, 10 Nov 2020 20:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605041410; bh=3hv5p5qekbgP0DrUGts71/2N8rvEWkFJnELYbEtqoIg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AVcBjBebzIYTXj/uoWrEU0i8ej5d9pL2T+Rg5ecvlKcYKd90KhzT1W1mED224VgFh DuP4ZLVAb1ldO+WVIpCpUgWlSfBADgW/EjZtkteq/fFGCe9LH4Mcj1VHUOOqz6h9UQ evSYM0HEXH7lGv2B2TdXLMhZ0kWQ1AQ8z+USNq/0= Date: Tue, 10 Nov 2020 12:50:08 -0800 From: Andrew Morton To: Roman Gushchin Cc: , Shakeel Butt , Johannes Weiner , Michal Hocko , Christoph Lameter , , Subject: Re: [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab caches with SLAB_ACCOUNT Message-Id: <20201110125008.003fb018e74c40109fd6723f@linux-foundation.org> In-Reply-To: <20201110195753.530157-2-guro@fb.com> References: <20201110195753.530157-1-guro@fb.com> <20201110195753.530157-2-guro@fb.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Nov 2020 11:57:53 -0800 Roman Gushchin wrote: > 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. Was there any measurable performance change from this?