* [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps
@ 2024-02-15 18:39 Juntong Deng
2024-02-15 22:27 ` Andrew Morton
2024-02-15 23:38 ` Andrey Konovalov
0 siblings, 2 replies; 3+ messages in thread
From: Juntong Deng @ 2024-02-15 18:39 UTC (permalink / raw)
To: ryabinin.a.a, glider, andreyknvl, dvyukov, vincenzo.frascino, akpm
Cc: kasan-dev, linux-mm, linux-kernel
Fix the mistake before, I thought printk only display 99999 seconds
at max, but actually printk can display larger number of seconds.
So increase the number of bits to shift when recording the extra
timestamp (44 bits), without affecting the precision, shift it right by
9 bits, discarding all bits that do not affect the microsecond part
(nanoseconds will not be shown).
Currently the maximum time that can be displayed is 9007199.254740s,
because
11111111111111111111111111111111111111111111 (44 bits) << 9
= 11111111111111111111111111111111111111111111000000000
= 9007199.254740
Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
---
mm/kasan/common.c | 2 +-
mm/kasan/report.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 6ca63e8dda74..e7c9a4dc89f8 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -55,7 +55,7 @@ void kasan_set_track(struct kasan_track *track, depot_stack_handle_t stack)
u64 ts_nsec = local_clock();
track->cpu = cpu;
- track->timestamp = ts_nsec >> 3;
+ track->timestamp = ts_nsec >> 9;
#endif /* CONFIG_KASAN_EXTRA_INFO */
track->pid = current->pid;
track->stack = stack;
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 7afa4feb03e1..b48c768acc84 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -267,7 +267,7 @@ static void print_track(struct kasan_track *track, const char *prefix)
u64 ts_nsec = track->timestamp;
unsigned long rem_usec;
- ts_nsec <<= 3;
+ ts_nsec <<= 9;
rem_usec = do_div(ts_nsec, NSEC_PER_SEC) / 1000;
pr_err("%s by task %u on cpu %d at %lu.%06lus:\n",
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps
2024-02-15 18:39 [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps Juntong Deng
@ 2024-02-15 22:27 ` Andrew Morton
2024-02-15 23:38 ` Andrey Konovalov
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2024-02-15 22:27 UTC (permalink / raw)
To: Juntong Deng
Cc: ryabinin.a.a, glider, andreyknvl, dvyukov, vincenzo.frascino,
kasan-dev, linux-mm, linux-kernel
On Thu, 15 Feb 2024 18:39:55 +0000 Juntong Deng <juntong.deng@outlook.com> wrote:
> Fix the mistake before,
This is rather imprecise ;)
I shall add to the changelog:
Fixes: 5d4c6ac94694 ("kasan: record and report more information")
> I thought printk only display 99999 seconds
> at max, but actually printk can display larger number of seconds.
>
> So increase the number of bits to shift when recording the extra
> timestamp (44 bits), without affecting the precision, shift it right by
> 9 bits, discarding all bits that do not affect the microsecond part
> (nanoseconds will not be shown).
>
> Currently the maximum time that can be displayed is 9007199.254740s,
> because
>
> 11111111111111111111111111111111111111111111 (44 bits) << 9
> = 11111111111111111111111111111111111111111111000000000
> = 9007199.254740
Another important thing to always changelog is the effect of the
bug/shortcoming upon our users. So that
a) others can decide whether the issue is serious enough to justify
backporting the fix into earlier Long Term Stable kernels and
b) people who maintain other kernel trees (of whom there are many)
are better able to determine whether this patch is likely to address
a report which they have received from their customers.
Because 99999 seconds is a very long time, I am assuming that the
effect of this upon our users is basically zero, so I shall not be
adding
Cc: <stable@vger.kernel.org>
to this patch's changelog.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps
2024-02-15 18:39 [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps Juntong Deng
2024-02-15 22:27 ` Andrew Morton
@ 2024-02-15 23:38 ` Andrey Konovalov
1 sibling, 0 replies; 3+ messages in thread
From: Andrey Konovalov @ 2024-02-15 23:38 UTC (permalink / raw)
To: Juntong Deng
Cc: ryabinin.a.a, glider, dvyukov, vincenzo.frascino, akpm,
kasan-dev, linux-mm, linux-kernel
On Thu, Feb 15, 2024 at 7:41 PM Juntong Deng <juntong.deng@outlook.com> wrote:
>
> Fix the mistake before, I thought printk only display 99999 seconds
> at max, but actually printk can display larger number of seconds.
>
> So increase the number of bits to shift when recording the extra
> timestamp (44 bits), without affecting the precision, shift it right by
> 9 bits, discarding all bits that do not affect the microsecond part
> (nanoseconds will not be shown).
>
> Currently the maximum time that can be displayed is 9007199.254740s,
> because
>
> 11111111111111111111111111111111111111111111 (44 bits) << 9
> = 11111111111111111111111111111111111111111111000000000
> = 9007199.254740
>
> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> ---
> mm/kasan/common.c | 2 +-
> mm/kasan/report.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index 6ca63e8dda74..e7c9a4dc89f8 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -55,7 +55,7 @@ void kasan_set_track(struct kasan_track *track, depot_stack_handle_t stack)
> u64 ts_nsec = local_clock();
>
> track->cpu = cpu;
> - track->timestamp = ts_nsec >> 3;
> + track->timestamp = ts_nsec >> 9;
> #endif /* CONFIG_KASAN_EXTRA_INFO */
> track->pid = current->pid;
> track->stack = stack;
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index 7afa4feb03e1..b48c768acc84 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -267,7 +267,7 @@ static void print_track(struct kasan_track *track, const char *prefix)
> u64 ts_nsec = track->timestamp;
> unsigned long rem_usec;
>
> - ts_nsec <<= 3;
> + ts_nsec <<= 9;
> rem_usec = do_div(ts_nsec, NSEC_PER_SEC) / 1000;
>
> pr_err("%s by task %u on cpu %d at %lu.%06lus:\n",
> --
> 2.39.2
>
Acked-by: Andrey Konovalov <andreyknvl@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-15 23:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15 18:39 [PATCH] kasan: Increase the number of bits to shift when recording extra timestamps Juntong Deng
2024-02-15 22:27 ` Andrew Morton
2024-02-15 23:38 ` Andrey Konovalov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox