Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3519560pxb; Mon, 4 Apr 2022 19:40:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPCqUzahzMQwi6gP588pQF0a17r0Nl4csy7X1EjatVNT7+8x+nTE9t6maRTYqAEgH6REPH X-Received: by 2002:a17:902:cec2:b0:154:6df6:1e6a with SMTP id d2-20020a170902cec200b001546df61e6amr1169104plg.58.1649126453621; Mon, 04 Apr 2022 19:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649126453; cv=none; d=google.com; s=arc-20160816; b=JZhWeugjbuvktWMDvTmSLYcZ2b1O0WxBq0u7bjaGyelEuZ1+0045I++Uqq2GobhzAr m5f2PXBdbUi3kdriUAEVXJkZ4AyrBh8WnjRv36ErCYS3l7gChT/DS+LOEFK7PM+PGywz uan5uSyaJdCvW36i9JtnIx/ZtNbdGflbFSWnZQtC3ztlvGNrqyo5kopLf/fz4gQk371R EgqPD6Th0qV0o5ma860PxflCo9GFmU9Fypsk16gaxom63ByX5HPA/eW1JNPUyAy8k+QQ eR26CuYHjsChTkQzpHpGUE5hscykb7NYYo2Kqg46GSs9R1/Lbr37Gy1vnGmpXCxJocHu 0MaA== 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:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=iaE2YvQWImFfSU0vpFQAVEvFm93nlCxWB9zb2gu0sPw=; b=iUlRWX90kEtz4MDgyLAH1n+kJ5c+LkYUoiQvSi7iUjKucENnorO6tQ1wjmtiDZ71n9 0dBUO6Pv/eP240pCTSMBzMguuj/kw3swHyeQ91mSo4O44NiTdbfpzjZE196nCqKs86ej w3HXum2FCOkx3iShBVepo+Rd27YVd5iqFGXrDyg8/ezDw+eH+e3IU/EGfiQyQ5dmqPYu IubWkYDTd8rEq2ILgVfZ8R3jHBdZvV7PQqN8d5ctnBmOfUeVD6YMv0z1PMtDfSbyC2Ga xhfYUZJ1EwYMcGp1V54/+iPgyo3hVySOSKxAIplm/KVg4kbyiR9VVJ1MNEY8B1EtRzGp V2qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Aq4DwyFi; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g14-20020a170902d5ce00b00153b2d16428si10731911plh.48.2022.04.04.19.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:40:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Aq4DwyFi; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E06B8329CA8; Mon, 4 Apr 2022 18:04:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383194AbiDDVlc (ORCPT + 99 others); Mon, 4 Apr 2022 17:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379199AbiDDQnS (ORCPT ); Mon, 4 Apr 2022 12:43:18 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8F835853 for ; Mon, 4 Apr 2022 09:41:21 -0700 (PDT) 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-out1.suse.de (Postfix) with ESMTPS id 52825210FC; Mon, 4 Apr 2022 16:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1649090480; 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=iaE2YvQWImFfSU0vpFQAVEvFm93nlCxWB9zb2gu0sPw=; b=Aq4DwyFirzDpf643d6LaNTryRKgg7O+NS/BhX6awzui5v67ahbF167x2uJ4IVhlqqB1Qhi I546Ma+WaIhbgy0P6wzM9k3qdJHuuc4qMYKDuWzkGSApqOUr5eG9GjQnQnEfJqldefGCdX 0n/qQKfOFnFxjqL/wSYI4V4vxsTBTy0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1649090480; 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=iaE2YvQWImFfSU0vpFQAVEvFm93nlCxWB9zb2gu0sPw=; b=eK5U25dTPANluiZzRfIbMte9s4p29IJQoGQ84fGRIy3pMoj0hICHeDPHIVww0a44zz0/Yp aIy7jm9OOTEOSADg== 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 228CB12FC5; Mon, 4 Apr 2022 16:41:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wOviB7AfS2LjfAAAMHmgww (envelope-from ); Mon, 04 Apr 2022 16:41:20 +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 , Marco Elver , Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Imran Khan , Vlastimil Babka Subject: [PATCH v3 2/6] mm/slub: move struct track init out of set_track() Date: Mon, 4 Apr 2022 18:41:08 +0200 Message-Id: <20220404164112.18372-3-vbabka@suse.cz> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220404164112.18372-1-vbabka@suse.cz> References: <20220404164112.18372-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2040; h=from:subject; bh=zs3eo+rtqVSox6il95y1GSalLVpmki26s9979QfrOMU=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBiSx+kjPN+TrSQnc6TZ653XW3JCx/kwZAczK0EOz/c Ron6iIiJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYksfpAAKCRDgIcpz8YmpEG23B/ 9nhTJhIIp33l1sFVO1vFJMQhAgm86MyxIu8FsrjB2606GdpWRVtTw2z5YRfxr9SPAT+ReeGrYbV2jH nRw1BKaEn2uaI7dmtMJbS8A02vJdQ81IYbuog734gHEBPcnwHGknA3EWHFvfoB+FuEWvVj8eYVTePg koaBMTKgjQf6C0oUAob9QxCeZNMZxFRYMyPk2BYwHsYT9cCKcq6URNkfdXkWZQn9BQaSvQDkwS90Vm 2BQDZOmCZkevFucPzODgaZ/2gBDNw6L0TUnwn3B8Fx3rrfyVFyDUB4K04DudJn1hy2SdwNvCOay3LY ejOVai4fUxxfY4gg4sqxTUB8XJXgxh X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 74d92aa4a3a2..cd4fd0159911 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) -- 2.35.1