From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Huacai Chen <chenhuacai@loongson.cn>
Cc: Arnd Bergmann <arnd@arndb.de>, Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Airlie <airlied@linux.ie>, Jonathan Corbet <corbet@lwn.net>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-arch@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, Xuefeng Li <lixuefeng@loongson.cn>,
Yanteng Si <siyanteng@loongson.cn>,
Huacai Chen <chenhuacai@gmail.com>, Guo Ren <guoren@kernel.org>,
Xuerui Wang <kernel@xen0n.name>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Stephen Rothwell <sfr@canb.auug.org.au>,
WANG Xuerui <git@xen0n.name>
Subject: Re: [PATCH V15 10/24] LoongArch: Add other common headers
Date: Fri, 3 Jun 2022 15:40:54 +0200 [thread overview]
Message-ID: <YpoPZjJ/Adfu3uH9@zx2c4.com> (raw)
In-Reply-To: <20220603072053.35005-11-chenhuacai@loongson.cn>
Hi Huacai,
On Fri, Jun 03, 2022 at 03:20:39PM +0800, Huacai Chen wrote:
> diff --git a/arch/loongarch/include/asm/timex.h b/arch/loongarch/include/asm/timex.h
> new file mode 100644
> index 000000000000..d3ed99a4fdbd
> --- /dev/null
> +++ b/arch/loongarch/include/asm/timex.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
> + */
> +#ifndef _ASM_TIMEX_H
> +#define _ASM_TIMEX_H
> +
> +#ifdef __KERNEL__
> +
> +#include <linux/compiler.h>
> +
> +#include <asm/cpu.h>
> +#include <asm/cpu-features.h>
> +
> +/*
> + * Standard way to access the cycle counter.
> + * Currently only used on SMP for scheduling.
> + *
> + * We know that all SMP capable CPUs have cycle counters.
> + */
> +
> +typedef unsigned long cycles_t;
> +
> +#define get_cycles get_cycles
> +
> +static inline cycles_t get_cycles(void)
> +{
> + return drdtime();
> +}
> +
> +#endif /* __KERNEL__ */
> +
> +#endif /* _ASM_TIMEX_H */
"Currently only used on SMP for scheduling" isn't quite correct. It's
also used by random_get_entropy(). And anything else that uses
get_cycles() for, e.g., benchmarking, might use it too.
You wrote also, "we know that all SMP capable CPUs have cycle counters",
so if I gather from this statement that some !SMP CPUs don't have a
cycle counter, though some do. If that's a correct supposition, then
you may need to rewrite this file to be something like:
static inline bool cpu_has_rdtime(void)
{
return IS_ENABLED(CONFIG_SMP) ? true : { ... some magic to determine on !SMP ... };
}
typedef unsigned long cycles_t;
static inline cycles_t get_cycles(void)
{
return cpu_has_rdtime() ? drdtime() : 0;
}
#define get_cycles get_cycles
static inline unsigned long random_get_entropy(void)
{
return cpu_has_rdtime() ? drdtime() : random_get_entropy_fallback();
}
#define random_get_entropy random_get_entropy
Does that make sense? More importantly, is my presumption about !SMP
correct?
In any case, please do CC me on this patch for v+1.
Regards,
Jason
next prev parent reply other threads:[~2022-06-03 13:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 7:20 [PATCH V15 00/24] arch: Add basic LoongArch support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 01/24] irqchip: Adjust Kconfig for Loongson Huacai Chen
2022-06-03 7:20 ` [PATCH V15 02/24] irqchip/loongson-liointc: Fix build error for LoongArch Huacai Chen
2022-06-03 7:20 ` [PATCH V15 03/24] Documentation: LoongArch: Add basic documentations Huacai Chen
2022-06-03 7:20 ` [PATCH V15 04/24] Documentation/zh_CN: Add basic LoongArch documentations Huacai Chen
2022-06-03 7:20 ` [PATCH V15 05/24] LoongArch: Add ELF-related definitions Huacai Chen
2022-06-03 7:20 ` [PATCH V15 06/24] LoongArch: Add writecombine support for drm Huacai Chen
2022-06-03 7:20 ` [PATCH V15 07/24] LoongArch: Add build infrastructure Huacai Chen
2022-06-03 7:20 ` [PATCH V15 08/24] LoongArch: Add CPU definition headers Huacai Chen
2022-06-03 7:20 ` [PATCH V15 09/24] LoongArch: Add atomic/locking headers Huacai Chen
2022-06-03 7:20 ` [PATCH V15 10/24] LoongArch: Add other common headers Huacai Chen
2022-06-03 13:40 ` Jason A. Donenfeld [this message]
2022-06-03 13:55 ` Arnd Bergmann
2022-06-03 14:01 ` Jason A. Donenfeld
2022-06-03 14:14 ` WANG Xuerui
2022-06-03 14:35 ` Huacai Chen
2022-06-04 6:38 ` Jason A. Donenfeld
2022-06-03 7:20 ` [PATCH V15 11/24] LoongArch: Add boot and setup routines Huacai Chen
2022-06-03 9:27 ` WANG Xuerui
2022-06-03 10:02 ` Arnd Bergmann
2022-06-03 10:37 ` WANG Xuerui
2022-06-03 11:48 ` Ard Biesheuvel
2022-06-03 7:20 ` [PATCH V15 12/24] LoongArch: Add exception/interrupt handling Huacai Chen
2022-06-03 7:20 ` [PATCH V15 13/24] LoongArch: Add process management Huacai Chen
2022-06-03 7:20 ` [PATCH V15 14/24] LoongArch: Add memory management Huacai Chen
2022-06-03 7:20 ` [PATCH V15 15/24] LoongArch: Add system call support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 16/24] LoongArch: Add signal handling support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 17/24] LoongArch: Add ELF and module support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 18/24] LoongArch: Add misc common routines Huacai Chen
2022-06-03 7:20 ` [PATCH V15 19/24] LoongArch: Add some library functions Huacai Chen
2022-06-03 7:20 ` [PATCH V15 20/24] LoongArch: Add VDSO and VSYSCALL support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 21/24] LoongArch: Add multi-processor (SMP) support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 22/24] LoongArch: Add Non-Uniform Memory Access (NUMA) support Huacai Chen
2022-06-03 7:20 ` [PATCH V15 23/24] LoongArch: Add Loongson-3 default config file Huacai Chen
2022-06-03 7:20 ` [PATCH V15 24/24] MAINTAINERS: Add maintainer information for LoongArch Huacai Chen
2022-06-03 9:14 ` [PATCH V15 00/24] arch: Add basic LoongArch support WANG Xuerui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YpoPZjJ/Adfu3uH9@zx2c4.com \
--to=jason@zx2c4.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chenhuacai@gmail.com \
--cc=chenhuacai@loongson.cn \
--cc=corbet@lwn.net \
--cc=git@xen0n.name \
--cc=guoren@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=sfr@canb.auug.org.au \
--cc=siyanteng@loongson.cn \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®