From nobody Tue Nov 08 18:14:31 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N6GTN14RKz4V5KL; Tue, 8 Nov 2022 18:14:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N6GTN0d8vz4HZm; Tue, 8 Nov 2022 18:14:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667931272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gINlzizMk3cooE9GFRcxksrkYgSM8CIogz5Z8nTD3JU=; b=mQ106GPUEpoY5moUupiQbRI94dOFltYYDeU0TlPDpd4EQSlfCJSbrTue4v0PFx8V/KOwka MaaG8zi/On49/rMHzDx/WnCwlF/P0PsG20bMPG7Zt9bvFN1dsgYDbd3FRgpqVZemmE9ORj mCQNgs8fNAKjttJombLwRtOsvd44ci6Ytgi9IrtGzn6YBBBDZ3xqo3S4kFPmzDgZ29EiSe Ipx9Qji4Kr9VCgcgbB1PEySvk9AB5D8FMiD/w7hH5tFFp61FFULr3sibpmWbykA9qbgBxX Hs5LNxiL0CJjOWA0Q1aoU3aJf888F1cjSxzQVAxOaHZvZpem8RRZa5EboRe+mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667931272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gINlzizMk3cooE9GFRcxksrkYgSM8CIogz5Z8nTD3JU=; b=L7pVtzr4u87rMMI6NTe3inF0ZrJltFGKtmxmzqlRlk4WxtHMZoKlQNmXp7RJpF3KPUN9gk ngToFve3xU9/QK64ABjieLXIy7l3xpIHInVaxMga3epg05MKF085e7g2HeLANSoxHk0KXZ Vyivxpuj596kF1+yJdkKyOJuX1ADpS1Z0MsDtRUJjc66YveUfWlgINL6rq0zNV4jjHvYWv 4EJG/3ARoqT8zEQc5X2lfwwGGtrmZJ8FpnUsbFA7zX2O3/LkMq0GOPRzHRbcPQflSF08a6 t9zhWfcBgDiqxIyYMh3lhOvSzZ7iZ11IOS5+hOhJUr8W5RB/DBflZw/QYuoP8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667931272; a=rsa-sha256; cv=none; b=Ha4QMH2uidYAPl3b8wClnPTvqskXLCD39ot66KfU+kCZ8cmchRMMgrHGjXTll1EOlxgCCi ghPTy6uTj07gq//W+F51MBMg6ZT7o3xHwhEftapwNuwBEK/YXu2IstClNOd5j1L0VXi4Xs iL8L79rUvHVR8qJa1idx1Z91VCBLFBHm+ca1C7df1U8U/oPhe+ynXFnvvQMmrsAAbDHvWN pTUeCMWQTlB226u916QM47Zn0v7orfDydR5v013iT8vcccdBfrUNkXcB3V+xHAvJNt2Exc Bv3m3Gc3BU7ZyyIFXW51ELBAhh2LMdUQg3BxBYi+7hpPzhkXbzOJjwNpIxFgiw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N6GTM6YT9zrdr; Tue, 8 Nov 2022 18:14:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A8IEVa3028269; Tue, 8 Nov 2022 18:14:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A8IEVlK028268; Tue, 8 Nov 2022 18:14:31 GMT (envelope-from git) Date: Tue, 8 Nov 2022 18:14:31 GMT Message-Id: <202211081814.2A8IEVlK028268@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: e2361e04b02a - main - LinuxKPI: implement cpumask_of() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2361e04b02aafa927c32c4f5a39e6fd96196082 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e2361e04b02aafa927c32c4f5a39e6fd96196082 commit e2361e04b02aafa927c32c4f5a39e6fd96196082 Author: Bjoern A. Zeeb AuthorDate: 2022-10-31 14:33:58 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-11-08 18:11:55 +0000 LinuxKPI: implement cpumask_of() Add a static set of cpumasks for all (possible) cpus with only the one indexed cpu enabled in each set. This is needed for cpumask_of(_cpuid) which returns a cpumask (cpuset) with only cpu _cpuid enabled and is used by one wireless driver at least. MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37223 --- sys/compat/linuxkpi/common/include/linux/cpu.h | 4 ++++ sys/compat/linuxkpi/common/src/linux_compat.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/cpu.h b/sys/compat/linuxkpi/common/include/linux/cpu.h index 53fa9db424c2..08e59b33e53a 100644 --- a/sys/compat/linuxkpi/common/include/linux/cpu.h +++ b/sys/compat/linuxkpi/common/include/linux/cpu.h @@ -44,6 +44,8 @@ typedef cpuset_t cpumask_t; extern cpumask_t cpu_online_mask; +cpumask_t *lkpi_get_static_single_cpu_mask(int); + static __inline int cpumask_next(int cpuid, cpumask_t mask) { @@ -73,4 +75,6 @@ cpumask_set_cpu(int cpu, cpumask_t *mask) CPU_SET(cpu, mask); } +#define cpumask_of(_cpu) (lkpi_get_static_single_cpu_mask(_cpu)) + #endif /* _LINUXKPI_LINUX_CPU_H */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 8c5d2e4ecd16..1367556a6f43 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -132,6 +132,7 @@ static void linux_cdev_deref(struct linux_cdev *ldev); static struct vm_area_struct *linux_cdev_handle_find(void *handle); cpumask_t cpu_online_mask; +static cpumask_t static_single_cpu_mask[MAXCPU]; struct kobject linux_class_root; struct device linux_root_device; struct class linux_class_misc; @@ -2734,6 +2735,16 @@ bool linux_cpu_has_clflush; struct cpuinfo_x86 boot_cpu_data; #endif +cpumask_t * +lkpi_get_static_single_cpu_mask(int cpuid) +{ + + KASSERT((cpuid >= 0 && cpuid < MAXCPU), ("%s: invalid cpuid %d\n", + __func__, cpuid)); + + return (&static_single_cpu_mask[cpuid]); +} + static void linux_compat_init(void *arg) { @@ -2771,6 +2782,15 @@ linux_compat_init(void *arg) init_waitqueue_head(&linux_var_waitq); CPU_COPY(&all_cpus, &cpu_online_mask); + /* + * Generate a single-CPU cpumask_t for each CPU (possibly) in the system. + * CPUs are indexed from 0..(MAXCPU-1). The entry for cpuid 0 will only + * have itself in the cpumask, cupid 1 only itself on entry 1, and so on. + * This is used by cpumask_of() (and possibly others in the future) for, + * e.g., drivers to pass hints to irq_set_affinity_hint(). + */ + for (i = 0; i < MAXCPU; i++) + CPU_SET(i, &static_single_cpu_mask[i]); } SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL);