Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp178569rdd; Wed, 22 Nov 2023 12:36:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeEcqHtIz+OIpCF5Avqv3jgWgg//ZcqIIOwkv7KNpJCsOApfM2BYJ3BNWgJdiyeuSWNKUO X-Received: by 2002:a05:6a20:12c5:b0:180:e3f1:4f60 with SMTP id v5-20020a056a2012c500b00180e3f14f60mr3633718pzg.45.1700685410921; Wed, 22 Nov 2023 12:36:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700685410; cv=none; d=google.com; s=arc-20160816; b=xKxRuWq5ib6SRbJBAhKRKCNB3eNvAwIMNfUg9/zKRWASG8st/6djdjlIA9p4L6CFiE ZdYdK9/a76M+ogbJ7Lzx9y011BMu7JMmtlHCLOkfu4QZKw/JHVAm4gp9t4pFhyWUyBaN E6/UaYMthb9tFyYLIiOlsI44P4LsfJc20c7KJyRfBZzRQNsJwEDeSSapAeYWM1VKL+2h N1zbnj75s1XIxgOkVfkdnM+LNV8E6p2AKhbp5G4FXO19E1UBq14yG7ZjkcnbFMUH+ulo AwvnEFg1YRkFpLF+kDhvCi4e7H9WU9wBPmzDM8zZ3KEf0T5bDTlDRBOqiQNZFxebtwuY Bwlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vkfEHr78Ys9Zl8oeeDr7y3wj216XnJVscyV3Cx1FHDQ=; fh=LubqLcB7navSDf0Nt52CtUnJ6CDCRU0TM1wxMFuJtiQ=; b=VCabMM54k58zGk/vxEHpXQ33D55b2cQNzq6mCNmqazSSNupET5q93Ko4O6SP/uw0AG N8ULKr3Qp35pZeSU56z9HEmvDnIWCHvGfZCtxO6HzEU6BlV8i9V13pdnBcrYSZJhGrFu JPnpYRXz1sErZiKJLCf5y5yCyNuy9CrEUsE9ErVzRQfmM7BCCD4dquNQAQsvfKCugiUO OssZ9chILywXH3/92Fh13NxaFuF5WWFOhKj5J9gh+uN5i4UO5QZlYj2L+84dGqiFIwuU YW5JQs/i6t6B/gLN7r9LMkWWg3aZAGeitBt7vV8M+2AOwW/Tq9qldwIU3lYnCwHS/s2p xjRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MQ8l00dM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s123-20020a625e81000000b006c320b98b74si237628pfb.369.2023.11.22.12.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 12:36:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MQ8l00dM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9102A8295770; Wed, 22 Nov 2023 12:36:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343957AbjKVUg2 (ORCPT + 99 others); Wed, 22 Nov 2023 15:36:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjKVUg1 (ORCPT ); Wed, 22 Nov 2023 15:36:27 -0500 Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAA81F9 for ; Wed, 22 Nov 2023 12:36:23 -0800 (PST) Received: by mail-ua1-x92e.google.com with SMTP id a1e0cc1a2514c-7ba9bd62fdfso56408241.3 for ; Wed, 22 Nov 2023 12:36:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700685383; x=1701290183; 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=vkfEHr78Ys9Zl8oeeDr7y3wj216XnJVscyV3Cx1FHDQ=; b=MQ8l00dM2/Itf7Ookpx8wtNASI7+PcC0hVzT3uLckQp6aMh2Tlq/ixTbpUXRBOUr2J +xFFDQXm3RX17PXKPXbm2DL2qnaCFHViY8jwjGpNByUPrJfyDFatnZUNIGyRjAwoERGy 9T5sMMLsCLI/CoYjDnjV3cEEw2qHiibn7DqIgFfZGQ8ivzsRUmkixPKOPdZzpUfAcyWa lxtm9/IBVs7LIWzTE7WE5VLpvlg8RFdoYn6EOUd43B7/AuWIcAwHTpyg2v+d5S7bbZuc Jmqwq0/GnN0Omgk4+XNxbUP9aJg+Z6NsQtZIFatNqj1fHLCwKftN/RMmBYvLCXK7QsRz Koqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700685383; x=1701290183; 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=vkfEHr78Ys9Zl8oeeDr7y3wj216XnJVscyV3Cx1FHDQ=; b=NXgcdko7OFt91k0dpawIZA3GOW7ECxpdmzsA17oHsfJWhrmiHmejJETKEty6u0YxAU NTir2FqCyKOEYuxxW9aR/K71G0qJ2vCXTX+2YPl5rxoA2eM/utzOfKSjeRM/8hBrqAMp 9Wl+8ocGaPz3M15KG0UtDDMp3i0y/tJkJ53+HbYZtk2wdjp3J1oz/YDHJ3mMkwxQtQMI rbPJx3j/kKL0QvWmFb4e7FEKckirjcR8WegcLOfwhlSlbGL4Rn0rmQYxETuN6VJf7LEe uGaEqan9YDm/uqt2ZBOgqWfiZQcohkd68BOyYhkUr+K0QTeUmfX4oT93R2dklL5+hEzD 2ykA== X-Gm-Message-State: AOJu0YyWnWTyU51DYfRSvvcKQ1fjFNOmAc26Mx1vkkkd1QM/3msfQ+Ca gniC+u55nK+N+w7l+lncLcYYYmTQtmapwjLQS8SkHg== X-Received: by 2002:a1f:4c04:0:b0:4ac:c52d:70f9 with SMTP id z4-20020a1f4c04000000b004acc52d70f9mr3579163vka.10.1700685382734; Wed, 22 Nov 2023 12:36:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Wed, 22 Nov 2023 21:35:44 +0100 Message-ID: Subject: Re: [PATCH] kfence: Replace local_clock() with ktime_get_boot_fast_ns() To: Juntong Deng Cc: glider@google.com, dvyukov@google.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 12:36:48 -0800 (PST) On Wed, 22 Nov 2023 at 21:01, Juntong Deng wrote: > > The time obtained by local_clock() is the local CPU time, which may > drift between CPUs and is not suitable for comparison across CPUs. > > It is possible for allocation and free to occur on different CPUs, > and using local_clock() to record timestamps may cause confusion. The same problem exists with printk logging. > ktime_get_boot_fast_ns() is based on clock sources and can be used > reliably and accurately for comparison across CPUs. You may be right here, however, the choice of local_clock() was deliberate: it's the same timestamp source that printk uses. Also, on systems where there is drift, the arch selects CONFIG_HAVE_UNSTABLE_SCHED_CLOCK (like on x86) and the drift is generally bounded. > Signed-off-by: Juntong Deng > --- > mm/kfence/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index 3872528d0963..041c03394193 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -295,7 +295,7 @@ metadata_update_state(struct kfence_metadata *meta, enum kfence_object_state nex > track->num_stack_entries = num_stack_entries; > track->pid = task_pid_nr(current); > track->cpu = raw_smp_processor_id(); > - track->ts_nsec = local_clock(); /* Same source as printk timestamps. */ > + track->ts_nsec = ktime_get_boot_fast_ns(); You have ignored the comment placed here - now it's no longer the same source as printk timestamps. I think not being able to correlate information from KFENCE reports with timestamps in lines from printk is worse. For now, I have to Nack: Unless you can prove that ktime_get_boot_fast_ns() can still be correlated with timestamps from printk timestamps, I think this change only trades one problem for another. Thanks, -- Marco