Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp392571rdb; Thu, 21 Dec 2023 12:11:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmiVmPhZq3I/C6G468QewXPBxdeDy+XUnyKoqJA8U/CJIQpC0OSzG1/Y8nwe/3oQQAjT+1 X-Received: by 2002:a17:902:7088:b0:1d0:6ffd:6119 with SMTP id z8-20020a170902708800b001d06ffd6119mr221135plk.59.1703189504949; Thu, 21 Dec 2023 12:11:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189504; cv=none; d=google.com; s=arc-20160816; b=XFnqbTvLWuEfYxJ/bq+FAWyrc4UkZfKm8wJl+Z2we3KymoKIfFyYEkv1upL//0s3NU lzMagkAc7NaM8iG4iqnojslrZiKUtiV8UQZgfQKcGLQHl6DmQAqzphCS2djA+D/BD4UZ 8XYzRoNfWi7UazYc49ApPRxWdl4wf4OHUAY+3KBJ29J3Y5v26iOMurKYcC5hNnNNZPmB v+mc4KDku6qyGMOE9XK1peOd0/iJnc2/LsIGfpgdRR2Ejz4UptSY8AYELneAHotZd4n3 jR6lAuSDO3esWqa6hDWwA6qIf3R8HbI1iB0ONUy2rQEpy/N41p5vTBAD3EN25+NaJ8+A ye3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=n71TmRIpLCKyJ+zhDPnh2JHDUhteUqmqWNotznqdT9E=; fh=Ahy40MSztyYZMnTonwM1XBgEig8egyoCalPOkrHuKkk=; b=yptqWI/kO9wf8QYZaX+v91zAAp0MB6Xgzd7+RFL4pXdSCUTgUB5pEPPtfur0ec6WSP Aq0ueqyAoem8zWBUe4ap4xsR+Wu/NvynN1CCbPViQKFBlPDh9K0ktbf1ceXbGkCp8ruI h89FhzZCgETA9WfAuUx+BL8P3fLFwLpila1OpO5ujxmJ8cT0DG2kl/XzQZyqI6jyep9f 8G6KzjoiQhth0tHaDnMPYkYI/4kG4mHRc5Pz2+gSGtJh6/gXltCUs6DtjRyZxyS/vk7u qaEMg+3neH7x8c8bSzjdX2ylISuHB/rbURUeC1I0A5fDnTKeBiZchQlp/eLm/ZwKX81g YrWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gOVege5L; spf=pass (google.com: domain of linux-kernel+bounces-9035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t24-20020a1709028c9800b001d3d8e7ac6esi1990376plo.51.2023.12.21.12.11.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:11:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gOVege5L; spf=pass (google.com: domain of linux-kernel+bounces-9035-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 02296B242D7 for ; Thu, 21 Dec 2023 20:11:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93713745C5; Thu, 21 Dec 2023 20:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gOVege5L" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BA0273185 for ; Thu, 21 Dec 2023 20:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2cc9fa5e8e1so12059671fa.3 for ; Thu, 21 Dec 2023 12:11:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703189487; x=1703794287; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=n71TmRIpLCKyJ+zhDPnh2JHDUhteUqmqWNotznqdT9E=; b=gOVege5LByP88rZ4oZAUShN+MUa+0DS02TtCVWEg2K59qr46sFVsgnZoAZQV574TRp g5Qedg3lOotXnu7PkUPsPSKLsi/wfYmCudWG6ELhajmE7GDjhxv+jp3S6N14UvSk30aV idugNf0KNwcry4vwOAK+gq1srZExpzK2g4nDzxmA4BqnznSYBG+/wUJa+xjuxXbQjjo9 eu74xm1ouUcFvewCHNoSSg4hytrDQMOeeAYrzK5fdiF+zJVIE2Nb+klownUX+yFZy9U7 qHAfo4Y6H8pGapr/Xkln47UefioM7mr0gbLV3DJ2U/SUZQyhgFiRp0vx+aHl/Q4n5ukI f4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703189487; x=1703794287; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n71TmRIpLCKyJ+zhDPnh2JHDUhteUqmqWNotznqdT9E=; b=DbS07zNYF7tOfQ0nG2/qNW5kRz3blhybvlALdUGLNzhID8zG5ulh2GAaUU6M6Ft6EZ BxrMPERrtf2rZO9mZ+6l1ARJHfUZr5laoDgHpdI86NQJDaSHXEHbfgwQqnAq7LqnqEFp Oz1AOVhyFQIhQKOJz/mA/poF834QyF2CdLjFuq1bwTiHmaYUS698lrcQz8IZbZyRDfVk HBKAGyPNDo23Mgpu6JLIbftOjMAQahE4+/38ytwys6DfzJF5xzdx7yj2IrEGhDwbv8fX +8qdR1lwFNvvJGxiYu6sZ9BZqJkijjy5fUIYZEkXkbTVKNaTYoXmGq47Sj7FtwuNUgPg Z4UA== X-Gm-Message-State: AOJu0Yy9AD1VMfpBg/XmQSU70E5L6iiljVRrSzIovVI3GvzAL6RTnwbK 6EhOHDNWjupQ+2dGajfrUqEJe9peOJwKGKsyhWsPIvQ90ElL X-Received: by 2002:a2e:b616:0:b0:2cc:8472:c97c with SMTP id r22-20020a2eb616000000b002cc8472c97cmr72870ljn.26.1703189487134; Thu, 21 Dec 2023 12:11:27 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221183540.168428-1-andrey.konovalov@linux.dev> <20231221183540.168428-2-andrey.konovalov@linux.dev> In-Reply-To: <20231221183540.168428-2-andrey.konovalov@linux.dev> From: Marco Elver Date: Thu, 21 Dec 2023 21:10:49 +0100 Message-ID: Subject: Re: [PATCH mm 2/4] kasan: reuse kasan_track in kasan_stack_ring_entry To: andrey.konovalov@linux.dev Cc: Andrew Morton , Juntong Deng , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" On Thu, 21 Dec 2023 at 19:35, wrote: > > From: Andrey Konovalov > > Avoid duplicating fields of kasan_track in kasan_stack_ring_entry: > reuse the structure. No functional change? > Fixes: 5d4c6ac94694 ("kasan: record and report more information") > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > mm/kasan/kasan.h | 7 +------ > mm/kasan/report_tags.c | 12 ++++++------ > mm/kasan/tags.c | 12 ++++++------ > 3 files changed, 13 insertions(+), 18 deletions(-) > > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h > index 5e298e3ac909..9072ce4c1263 100644 > --- a/mm/kasan/kasan.h > +++ b/mm/kasan/kasan.h > @@ -279,13 +279,8 @@ struct kasan_free_meta { > struct kasan_stack_ring_entry { > void *ptr; > size_t size; > - u32 pid; > - depot_stack_handle_t stack; > + struct kasan_track track; > bool is_free; > -#ifdef CONFIG_KASAN_EXTRA_INFO > - u64 cpu:20; > - u64 timestamp:44; > -#endif /* CONFIG_KASAN_EXTRA_INFO */ > }; > > struct kasan_stack_ring { > diff --git a/mm/kasan/report_tags.c b/mm/kasan/report_tags.c > index 979f284c2497..688b9d70b04a 100644 > --- a/mm/kasan/report_tags.c > +++ b/mm/kasan/report_tags.c > @@ -31,8 +31,8 @@ static const char *get_common_bug_type(struct kasan_report_info *info) > static void kasan_complete_extra_report_info(struct kasan_track *track, > struct kasan_stack_ring_entry *entry) > { > - track->cpu = entry->cpu; > - track->timestamp = entry->timestamp; > + track->cpu = entry->track.cpu; > + track->timestamp = entry->track.timestamp; > } > #endif /* CONFIG_KASAN_EXTRA_INFO */ > > @@ -80,8 +80,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) > if (free_found) > break; > > - info->free_track.pid = entry->pid; > - info->free_track.stack = entry->stack; > + info->free_track.pid = entry->track.pid; > + info->free_track.stack = entry->track.stack; > #ifdef CONFIG_KASAN_EXTRA_INFO > kasan_complete_extra_report_info(&info->free_track, entry); > #endif /* CONFIG_KASAN_EXTRA_INFO */ > @@ -98,8 +98,8 @@ void kasan_complete_mode_report_info(struct kasan_report_info *info) > if (alloc_found) > break; > > - info->alloc_track.pid = entry->pid; > - info->alloc_track.stack = entry->stack; > + info->alloc_track.pid = entry->track.pid; > + info->alloc_track.stack = entry->track.stack; > #ifdef CONFIG_KASAN_EXTRA_INFO > kasan_complete_extra_report_info(&info->alloc_track, entry); > #endif /* CONFIG_KASAN_EXTRA_INFO */ > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c > index c13b198b8302..c4d14dbf27c0 100644 > --- a/mm/kasan/tags.c > +++ b/mm/kasan/tags.c > @@ -100,8 +100,8 @@ static void save_extra_info(struct kasan_stack_ring_entry *entry) > u32 cpu = raw_smp_processor_id(); > u64 ts_nsec = local_clock(); > > - entry->cpu = cpu; > - entry->timestamp = ts_nsec >> 3; > + entry->track.cpu = cpu; > + entry->track.timestamp = ts_nsec >> 3; > } > #endif /* CONFIG_KASAN_EXTRA_INFO */ > > @@ -134,15 +134,15 @@ static void save_stack_info(struct kmem_cache *cache, void *object, > if (!try_cmpxchg(&entry->ptr, &old_ptr, STACK_RING_BUSY_PTR)) > goto next; /* Busy slot. */ > > - old_stack = entry->stack; > + old_stack = entry->track.stack; > > entry->size = cache->object_size; > - entry->pid = current->pid; > - entry->stack = stack; > - entry->is_free = is_free; > + entry->track.pid = current->pid; > + entry->track.stack = stack; > #ifdef CONFIG_KASAN_EXTRA_INFO > save_extra_info(entry); > #endif /* CONFIG_KASAN_EXTRA_INFO */ > + entry->is_free = is_free; > > entry->ptr = object; > > -- > 2.25.1 >