Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp35980lqg; Wed, 10 Apr 2024 14:33:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfLUOx5sFR+iagU+zaUEjl4Jr/sMnJEUwbVlnpjJJ3qYSA6dQT5YR4/I+JVWtxFUMuHsN8t4qbxTG0iCB51BJ8Mr/cWF9Np5/cGyXv3A== X-Google-Smtp-Source: AGHT+IGbj0MbqDbyqsbSOyyZ0Sx9w1JuXPFv6ua6HAisLSsO9xPOLO/PlRGyZ4pxeOtTXw2KpbP5 X-Received: by 2002:a05:6a20:9696:b0:1a7:60fa:b324 with SMTP id hp22-20020a056a20969600b001a760fab324mr3529484pzc.18.1712784799392; Wed, 10 Apr 2024 14:33:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712784799; cv=pass; d=google.com; s=arc-20160816; b=wXmS2G212oEy/HCfjEFFs6ly7L5P0vEY9gkIbYVboa094EuhEsyF/myHhoK2dconBP 5NJsUBZy6bwupKHun8XU6h82fIIYf7KFxzj+gC8gH5ySPFJq7z6opPxdpQ05NVFyRXuG hueK/NcsaOYEY2gvaSlnKm0SCYCvmUzFM3oqD5IVvh7Jw1aizTmSmGV+TAJb4Xt/maV+ x7C7tCs4WKpoUNyWlMGm55bgwXMQ3cEeGDxfF5qz/0EV3u+fVOhMBFrfGCngqY0O+LGb pf2iJDwkTYt9KCf2ZX5xeF97hAfJyb19NggPOGTG/xng5Lt4373Rtt8XX+uBVXwQJ9Qy 2qRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=nh8OJkypTZN2dIacuWiBicR/c4idFBZIzTy0pVZ35ws=; fh=oTfnMkrO0+0fkJmoKG+FKoQOrPBfQ3H/73m59x6tfT4=; b=idzuSUJW3rz7bPRZoLjdZ/V4R1JAwfdvwmNFVA6G/+Vjgf8DepnkwwDnEubiQzywVA 0Ub6g02lJbtvTz0lw4HV7S7BHFYQOLDTcmFxgdjKNsCWqJoRhkNWD0sS2ts/3zWskywR HF9KJ9cXPg15ezi6AdPUH5k1MSnXLg7nTkCexhRWeyMFlGFAA5Z5pvxOgKCmvi7mv1X1 4+FF/hQF+Zi7mHrwm/aHAOQdBT9M+7oYr9YnjYLdi+oEOADW1r1++jMyR7eKTNXbSA1Q VQdxg4AnGbMl/V4P29qytFqmwgOO+uX5wwdUbvo+PkjVRm7sabpCiKB5z/CF4eh8Foy3 YF2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cjZIlLaL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-139374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i15-20020a170902c94f00b001e4063f59a9si21315pla.107.2024.04.10.14.33.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 14:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cjZIlLaL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-139374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 13259282148 for ; Wed, 10 Apr 2024 21:33:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2EF818413A; Wed, 10 Apr 2024 21:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cjZIlLaL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nV7PBw92" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E891836F3; Wed, 10 Apr 2024 21:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712784771; cv=none; b=hEO78MJBwrh3jPn7aoKtiO0i8jxRdva++BftTt6UmFT5KkKrx6eAKlJWZliSMRqIeGNnELuYrgIM3nCulHAA+MW4pr2GeEXv0yILSxR8hM+Q7HUUSyXG1ClvRM6OEK9/6xRb8i9t8kyinMYp/mkK2tdxNhS6DJWdDLMGFoiAdnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712784771; c=relaxed/simple; bh=uPaan8WWeNrf7KcvhIYFP+9mQ3Jap9iTRzy0ugpH7BU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=dSWxhtMY4YIchHAPzwAfvkDt4R8w4qI8CLTgfxY46v3HCCCwlX6HVgcpV4yMDoXwkLHUCOlRRtl8QcZavVk4G7/Uinea7QPPn/swZ1dRaR/YFwXUzql0oAEo1UiwXm3ZYbMOBqgCyXbkIGs7xy96v68y/XUpDm34Djr8X/D/LrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cjZIlLaL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nV7PBw92; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712784767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nh8OJkypTZN2dIacuWiBicR/c4idFBZIzTy0pVZ35ws=; b=cjZIlLaL/PET73d27bxQlie5EjJ9KCuctB85P00To/7BKeKXkrRLZKwPkflv6XDInOeerx SYrs+aLDhP34tezZuQ77WhJ/aBHrY9wjSRib7PnKXWawOBOLOaifubvCZOMmkA/WsWNrkH tQPDQyPuOa+hNZjY8Bbl7N/vHusGJTFQYvRu6+DYQn1cNkZCNgSGbrJ+q6rNhhmb5lp3N+ 3poKBGia6ReXtFAEA4uM2gTKqOROS+34+hyarZ5Njq9FjIiOQS3Gn6sCpsKF54Cv9Bxyp7 AyjUU/mnMozhgiNZV2MyTLzsjgOSXYlGwp+V4Y+1Zr/QadVb0yY+cso9P/ouwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712784767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nh8OJkypTZN2dIacuWiBicR/c4idFBZIzTy0pVZ35ws=; b=nV7PBw924lPvBzqrI/DpQb1r5WYRKGXbBipF/QylDBVVWVk2N5W4vkOtRlhcxuBm8quLJH XhR5wRV5qwpOLsDg== To: lakshmi.sowjanya.d@intel.com, jstultz@google.com, giometti@enneenne.com, corbet@lwn.net, linux-kernel@vger.kernel.org Cc: x86@kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, intel-wired-lan@lists.osuosl.org, andriy.shevchenko@linux.intel.com, eddie.dong@intel.com, christopher.s.hall@intel.com, jesse.brandeburg@intel.com, davem@davemloft.net, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, perex@perex.cz, linux-sound@vger.kernel.org, anthony.l.nguyen@intel.com, peter.hilber@opensynergy.com, pandith.n@intel.com, subramanian.mohan@intel.com, thejesh.reddy.t.r@intel.com, lakshmi.sowjanya.d@intel.com Subject: Re: [PATCH v6 01/11] x86/tsc: Add base clock properties in clocksource structure In-Reply-To: <20240410114828.25581-2-lakshmi.sowjanya.d@intel.com> References: <20240410114828.25581-1-lakshmi.sowjanya.d@intel.com> <20240410114828.25581-2-lakshmi.sowjanya.d@intel.com> Date: Wed, 10 Apr 2024 23:32:46 +0200 Message-ID: <87cyqw3nup.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Apr 10 2024 at 17:18, lakshmi.sowjanya.d@intel.com wrote: > @@ -48,6 +49,7 @@ struct module; > * @archdata: Optional arch-specific data > * @max_cycles: Maximum safe cycle value which won't overflow on > * multiplication > + * @freq_khz: Clocksource frequency in khz. > * @name: Pointer to clocksource name > * @list: List head for registration (internal) > * @rating: Rating value for selection (higher is better) > @@ -70,6 +72,8 @@ struct module; > * validate the clocksource from which the snapshot was > * taken. > * @flags: Flags describing special properties > + * @base: Hardware abstraction for clock on which a clocksource > + * is based > * @enable: Optional function to enable the clocksource > * @disable: Optional function to disable the clocksource > * @suspend: Optional suspend function for the clocksource > @@ -105,12 +109,14 @@ struct clocksource { > struct arch_clocksource_data archdata; > #endif > u64 max_cycles; > + u32 freq_khz; Q: Why is this a bad place to add this member? A: Because it creates a 4 byte hole in the data structure. > const char *name; > struct list_head list; While adding it here fills a 4 byte hole. Hint: pahole -c clocksource kernel/time/clocksource.o would have told you that. > int rating; > enum clocksource_ids id; > enum vdso_clock_mode vdso_clock_mode; > unsigned long flags; > + struct clocksource_base *base; > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index b58dffc58a8f..2542cfefbdee 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -1193,6 +1193,40 @@ static bool timestamp_in_interval(u64 start, u64 end, u64 ts) > return false; > } > > +static bool convert_clock(u64 *val, u32 numerator, u32 denominator) > +{ > + u64 rem, res; > + > + if (!numerator || !denominator) > + return false; > + > + res = div64_u64_rem(*val, denominator, &rem) * numerator; > + *val = res + div_u64(rem * numerator, denominator); > + return true; > +} > + > +static bool convert_base_to_cs(struct system_counterval_t *scv) > +{ > + struct clocksource *cs = tk_core.timekeeper.tkr_mono.clock; > + struct clocksource_base *base = cs->base; > + u32 num, den; > + > + /* The timestamp was taken from the time keeper clock source */ > + if (cs->id == scv->cs_id) > + return true; > + > + /* Check whether cs_id matches the base clock */ > + if (!base || base->id != scv->cs_id) > + return false; > + > + num = scv->use_nsecs ? cs->freq_khz : base->numerator; > + den = scv->use_nsecs ? USEC_PER_SEC : base->denominator; > + > + convert_clock(&scv->cycles, num, den); Q: Why does this ignore the return value of convert_clock() ? A: Because all drivers will correctly fill in everything. Q: Then why does convert_clock() bother to check and have a return value? A: Because drivers will fail to correctly fill in everything Thanks, tglx