From patchwork Wed Mar 2 17:31:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12766414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD613C433F5 for ; Wed, 2 Mar 2022 17:31:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11DB58D0005; Wed, 2 Mar 2022 12:31:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 029B18D0001; Wed, 2 Mar 2022 12:31:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1DCF8D0005; Wed, 2 Mar 2022 12:31:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id AB4298D0003 for ; Wed, 2 Mar 2022 12:31:38 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 683BB8248D52 for ; Wed, 2 Mar 2022 17:31:38 +0000 (UTC) X-FDA: 79200138276.21.5371FE4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf26.hostedemail.com (Postfix) with ESMTP id B0CAE14000F for ; Wed, 2 Mar 2022 17:31:37 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 796F41F3A3; Wed, 2 Mar 2022 17:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646242296; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r1N7lHefdQdRLrZdn0IGuF8+VmMNKPWirbLjcNDxaGY=; b=IDwyu0HRPpEDdX3qH4wxSuf3FbtkW1Sq3zxn73spk4TX9GhT7sboFX1MKRmUJf/VjurR3q h18ttIBZcoYyZaas0UDCc9F87KDQn17wA0zUPj53iZTIEAnyff6E+4l+LBCG6wFyi6naEP AX/eb9Xqo+YXAXPDlwjMDgLmEa6p5Eo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646242296; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r1N7lHefdQdRLrZdn0IGuF8+VmMNKPWirbLjcNDxaGY=; b=aTf+RLXTMppbndGTrpCm9edJUqcEcfS5SqBs3R2NtOewR+I8RTE9HLYSpbcwrSVbOB56qo MFwg4DkR8mkP70Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3D91213A89; Wed, 2 Mar 2022 17:31:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +Cz/DfipH2LPTAAAMHmgww (envelope-from ); Wed, 02 Mar 2022 17:31:36 +0000 From: Vlastimil Babka To: David Rientjes , Christoph Lameter , Joonsoo Kim , Pekka Enberg , Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Oliver Glitta , Faiyaz Mohammed , Marco Elver , Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Imran Khan , Vlastimil Babka Subject: [PATCH v2 2/6] mm/slub: move struct track init out of set_track() Date: Wed, 2 Mar 2022 18:31:18 +0100 Message-Id: <20220302173122.11939-3-vbabka@suse.cz> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302173122.11939-1-vbabka@suse.cz> References: <20220302173122.11939-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2040; h=from:subject; bh=5V02Ql5Wwt6ho1BAsi4n/qBKIm2FLxfXUIJYaK6h4Vs=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBiH6nmjmJgS1lZ546XQoaxj+A8/9t1bG5DvArQgDFu 1xtN6hKJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYh+p5gAKCRDgIcpz8YmpECZ9CA Co15DjumUXFzKv14uunJSKOZY7cWSOuXlRF6M8bUCvUOz9SQPLNEVYQ6NA99DDIQltLe8NcWBlkIL0 nMFZpxbLP754+v0Tb5apmx2f/ixA9Uh8ja/gUAQ/h7AnVyD50tXpZ3uW2cYcoDRuCQIqtu+k7QBAml neMcM5aglvuFzaXdfZhR8kO92sZEnzpBJDPn2XiV/tyn+2F1H6FOYv2GE+BD7Z83KjeIb0i4mqxrLQ eVGTEmQxMsN1Fe81Z8zyaqSQevtlivkIUqwEaEi4QZQsjo7XTkrtvtR22ZmdUYegp0qhmjjwesmCdn p/08XmwOt9k25L46Isho9OYs3qL04V X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B0CAE14000F X-Stat-Signature: s3j6try3rijr5b374tr9g6ce3kw15bff Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IDwyu0HR; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aTf+RLXT; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspam-User: X-HE-Tag: 1646242297-830479 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: set_track() either zeroes out the struct track or fills it, depending on the addr parameter. This is unnecessary as there's only one place that calls it for the initialization - init_tracking(). We can simply do the zeroing there, with a single memset() that covers both TRACK_ALLOC and TRACK_FREE as they are adjacent. Signed-off-by: Vlastimil Babka Reviewed-and-tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 261474092e43..1fc451f4fe62 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -729,34 +729,32 @@ static void set_track(struct kmem_cache *s, void *object, { struct track *p = get_track(s, object, alloc); - if (addr) { #ifdef CONFIG_STACKTRACE - unsigned int nr_entries; + unsigned int nr_entries; - metadata_access_enable(); - nr_entries = stack_trace_save(kasan_reset_tag(p->addrs), - TRACK_ADDRS_COUNT, 3); - metadata_access_disable(); + metadata_access_enable(); + nr_entries = stack_trace_save(kasan_reset_tag(p->addrs), + TRACK_ADDRS_COUNT, 3); + metadata_access_disable(); - if (nr_entries < TRACK_ADDRS_COUNT) - p->addrs[nr_entries] = 0; + if (nr_entries < TRACK_ADDRS_COUNT) + p->addrs[nr_entries] = 0; #endif - p->addr = addr; - p->cpu = smp_processor_id(); - p->pid = current->pid; - p->when = jiffies; - } else { - memset(p, 0, sizeof(struct track)); - } + p->addr = addr; + p->cpu = smp_processor_id(); + p->pid = current->pid; + p->when = jiffies; } static void init_tracking(struct kmem_cache *s, void *object) { + struct track *p; + if (!(s->flags & SLAB_STORE_USER)) return; - set_track(s, object, TRACK_FREE, 0UL); - set_track(s, object, TRACK_ALLOC, 0UL); + p = get_track(s, object, TRACK_ALLOC); + memset(p, 0, 2*sizeof(struct track)); } static void print_track(const char *s, struct track *t, unsigned long pr_time)