mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 05:17:10 +09:00
Merge tag 'v6.1.75'
This is the 6.1.75 stable release * tag 'v6.1.75': (2623 commits) Linux 6.1.75 Revert "Revert "md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d"" arm64: dts: armada-3720-turris-mox: set irq type for RTC Revert "KEYS: encrypted: Add check for strsep" riscv: Fix wrong usage of lm_alias() when splitting a huge linear mapping block: Remove special-casing of compound pages i2c: s3c24xx: fix transferring more than one message in polling mode i2c: s3c24xx: fix read transfers in polling mode ipv6: mcast: fix data-race in ipv6_mc_down / mld_ifc_work selftests: mlxsw: qos_pfc: Adjust the test to support 8 lanes mlxsw: spectrum_acl_erp: Fix error flow of pool allocation failure loop: fix the the direct I/O support check when used on top of block devices ethtool: netlink: Add missing ethnl_ops_begin/complete kdb: Fix a potential buffer overflow in kdb_local() ipvs: avoid stat macros calls from preemptible context netfilter: nf_tables: reject NFT_SET_CONCAT with not field length description netfilter: nf_tables: skip dead set elements in netlink dump netfilter: nf_tables: do not allow mismatch field size and set key length netfilter: bridge: replace physindev with physinif in nf_bridge_info netfilter: propagate net to nf_bridge_get_physindev ... Conflicts: drivers/clk/rockchip/clk-rk3568.c drivers/devfreq/event/rockchip-dfi.c drivers/gpu/drm/rockchip/rockchip_drm_vop.c drivers/gpu/drm/rockchip/rockchip_drm_vop2.c drivers/i2c/busses/i2c-rk3x.c drivers/i2c/i2c-core-base.c drivers/net/ethernet/stmicro/stmmac/stmmac_main.c drivers/nvme/host/nvme.h Change-Id: I9649ece83925659bca59cced0be24f0bd165822a Signed-off-by: Sandy Huang <hjc@rock-chips.com> Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
@@ -368,6 +368,15 @@ config PAHOLE_HAS_BTF_TAG
|
||||
btf_decl_tag) or not. Currently only clang compiler implements
|
||||
these attributes, so make the config depend on CC_IS_CLANG.
|
||||
|
||||
config PAHOLE_HAS_LANG_EXCLUDE
|
||||
def_bool PAHOLE_VERSION >= 124
|
||||
help
|
||||
Support for the --lang_exclude flag which makes pahole exclude
|
||||
compilation units from the supplied language. Used in Kbuild to
|
||||
omit Rust CUs which are not supported in version 1.24 of pahole,
|
||||
otherwise it would emit malformed kernel and module binaries when
|
||||
using DEBUG_INFO_BTF_MODULES.
|
||||
|
||||
config DEBUG_INFO_BTF_MODULES
|
||||
def_bool y
|
||||
depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF
|
||||
@@ -1234,13 +1243,16 @@ config DEBUG_TIMEKEEPING
|
||||
config DEBUG_PREEMPT
|
||||
bool "Debug preemptible kernel"
|
||||
depends on DEBUG_KERNEL && PREEMPTION && TRACE_IRQFLAGS_SUPPORT
|
||||
default y
|
||||
help
|
||||
If you say Y here then the kernel will use a debug variant of the
|
||||
commonly used smp_processor_id() function and will print warnings
|
||||
if kernel code uses it in a preemption-unsafe way. Also, the kernel
|
||||
will detect preemption count underflows.
|
||||
|
||||
This option has potential to introduce high runtime overhead,
|
||||
depending on workload as it triggers debugging routines for each
|
||||
this_cpu operation. It should only be used for debugging purposes.
|
||||
|
||||
menu "Lock Debugging (spinlocks, mutexes, etc...)"
|
||||
|
||||
config LOCK_DEBUGGING_SUPPORT
|
||||
|
||||
@@ -361,6 +361,8 @@ obj-$(CONFIG_SBITMAP) += sbitmap.o
|
||||
|
||||
obj-$(CONFIG_PARMAN) += parman.o
|
||||
|
||||
obj-y += group_cpus.o
|
||||
|
||||
# GCC library routines
|
||||
obj-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o
|
||||
obj-$(CONFIG_GENERIC_LIB_ASHRDI3) += ashrdi3.o
|
||||
|
||||
@@ -111,9 +111,6 @@ static const char *names_0[] = {
|
||||
E(ENOSPC),
|
||||
E(ENOSR),
|
||||
E(ENOSTR),
|
||||
#ifdef ENOSYM
|
||||
E(ENOSYM),
|
||||
#endif
|
||||
E(ENOSYS),
|
||||
E(ENOTBLK),
|
||||
E(ENOTCONN),
|
||||
@@ -144,9 +141,6 @@ static const char *names_0[] = {
|
||||
#endif
|
||||
E(EREMOTE),
|
||||
E(EREMOTEIO),
|
||||
#ifdef EREMOTERELEASE
|
||||
E(EREMOTERELEASE),
|
||||
#endif
|
||||
E(ERESTART),
|
||||
E(ERFKILL),
|
||||
E(EROFS),
|
||||
|
||||
@@ -166,6 +166,10 @@ void *__genradix_iter_peek(struct genradix_iter *iter,
|
||||
struct genradix_root *r;
|
||||
struct genradix_node *n;
|
||||
unsigned level, i;
|
||||
|
||||
if (iter->offset == SIZE_MAX)
|
||||
return NULL;
|
||||
|
||||
restart:
|
||||
r = READ_ONCE(radix->root);
|
||||
if (!r)
|
||||
@@ -184,10 +188,17 @@ restart:
|
||||
(GENRADIX_ARY - 1);
|
||||
|
||||
while (!n->children[i]) {
|
||||
size_t objs_per_ptr = genradix_depth_size(level);
|
||||
|
||||
if (iter->offset + objs_per_ptr < iter->offset) {
|
||||
iter->offset = SIZE_MAX;
|
||||
iter->pos = SIZE_MAX;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i++;
|
||||
iter->offset = round_down(iter->offset +
|
||||
genradix_depth_size(level),
|
||||
genradix_depth_size(level));
|
||||
iter->offset = round_down(iter->offset + objs_per_ptr,
|
||||
objs_per_ptr);
|
||||
iter->pos = (iter->offset >> PAGE_SHIFT) *
|
||||
objs_per_page;
|
||||
if (i == GENRADIX_ARY)
|
||||
|
||||
438
lib/group_cpus.c
Normal file
438
lib/group_cpus.c
Normal file
@@ -0,0 +1,438 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2016 Thomas Gleixner.
|
||||
* Copyright (C) 2016-2017 Christoph Hellwig.
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/sort.h>
|
||||
#include <linux/group_cpus.h>
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk,
|
||||
unsigned int cpus_per_grp)
|
||||
{
|
||||
const struct cpumask *siblmsk;
|
||||
int cpu, sibl;
|
||||
|
||||
for ( ; cpus_per_grp > 0; ) {
|
||||
cpu = cpumask_first(nmsk);
|
||||
|
||||
/* Should not happen, but I'm too lazy to think about it */
|
||||
if (cpu >= nr_cpu_ids)
|
||||
return;
|
||||
|
||||
cpumask_clear_cpu(cpu, nmsk);
|
||||
cpumask_set_cpu(cpu, irqmsk);
|
||||
cpus_per_grp--;
|
||||
|
||||
/* If the cpu has siblings, use them first */
|
||||
siblmsk = topology_sibling_cpumask(cpu);
|
||||
for (sibl = -1; cpus_per_grp > 0; ) {
|
||||
sibl = cpumask_next(sibl, siblmsk);
|
||||
if (sibl >= nr_cpu_ids)
|
||||
break;
|
||||
if (!cpumask_test_and_clear_cpu(sibl, nmsk))
|
||||
continue;
|
||||
cpumask_set_cpu(sibl, irqmsk);
|
||||
cpus_per_grp--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static cpumask_var_t *alloc_node_to_cpumask(void)
|
||||
{
|
||||
cpumask_var_t *masks;
|
||||
int node;
|
||||
|
||||
masks = kcalloc(nr_node_ids, sizeof(cpumask_var_t), GFP_KERNEL);
|
||||
if (!masks)
|
||||
return NULL;
|
||||
|
||||
for (node = 0; node < nr_node_ids; node++) {
|
||||
if (!zalloc_cpumask_var(&masks[node], GFP_KERNEL))
|
||||
goto out_unwind;
|
||||
}
|
||||
|
||||
return masks;
|
||||
|
||||
out_unwind:
|
||||
while (--node >= 0)
|
||||
free_cpumask_var(masks[node]);
|
||||
kfree(masks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void free_node_to_cpumask(cpumask_var_t *masks)
|
||||
{
|
||||
int node;
|
||||
|
||||
for (node = 0; node < nr_node_ids; node++)
|
||||
free_cpumask_var(masks[node]);
|
||||
kfree(masks);
|
||||
}
|
||||
|
||||
static void build_node_to_cpumask(cpumask_var_t *masks)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
for_each_possible_cpu(cpu)
|
||||
cpumask_set_cpu(cpu, masks[cpu_to_node(cpu)]);
|
||||
}
|
||||
|
||||
static int get_nodes_in_cpumask(cpumask_var_t *node_to_cpumask,
|
||||
const struct cpumask *mask, nodemask_t *nodemsk)
|
||||
{
|
||||
int n, nodes = 0;
|
||||
|
||||
/* Calculate the number of nodes in the supplied affinity mask */
|
||||
for_each_node(n) {
|
||||
if (cpumask_intersects(mask, node_to_cpumask[n])) {
|
||||
node_set(n, *nodemsk);
|
||||
nodes++;
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
struct node_groups {
|
||||
unsigned id;
|
||||
|
||||
union {
|
||||
unsigned ngroups;
|
||||
unsigned ncpus;
|
||||
};
|
||||
};
|
||||
|
||||
static int ncpus_cmp_func(const void *l, const void *r)
|
||||
{
|
||||
const struct node_groups *ln = l;
|
||||
const struct node_groups *rn = r;
|
||||
|
||||
return ln->ncpus - rn->ncpus;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate group number for each node, so that for each node:
|
||||
*
|
||||
* 1) the allocated number is >= 1
|
||||
*
|
||||
* 2) the allocated number is <= active CPU number of this node
|
||||
*
|
||||
* The actual allocated total groups may be less than @numgrps when
|
||||
* active total CPU number is less than @numgrps.
|
||||
*
|
||||
* Active CPUs means the CPUs in '@cpu_mask AND @node_to_cpumask[]'
|
||||
* for each node.
|
||||
*/
|
||||
static void alloc_nodes_groups(unsigned int numgrps,
|
||||
cpumask_var_t *node_to_cpumask,
|
||||
const struct cpumask *cpu_mask,
|
||||
const nodemask_t nodemsk,
|
||||
struct cpumask *nmsk,
|
||||
struct node_groups *node_groups)
|
||||
{
|
||||
unsigned n, remaining_ncpus = 0;
|
||||
|
||||
for (n = 0; n < nr_node_ids; n++) {
|
||||
node_groups[n].id = n;
|
||||
node_groups[n].ncpus = UINT_MAX;
|
||||
}
|
||||
|
||||
for_each_node_mask(n, nodemsk) {
|
||||
unsigned ncpus;
|
||||
|
||||
cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]);
|
||||
ncpus = cpumask_weight(nmsk);
|
||||
|
||||
if (!ncpus)
|
||||
continue;
|
||||
remaining_ncpus += ncpus;
|
||||
node_groups[n].ncpus = ncpus;
|
||||
}
|
||||
|
||||
numgrps = min_t(unsigned, remaining_ncpus, numgrps);
|
||||
|
||||
sort(node_groups, nr_node_ids, sizeof(node_groups[0]),
|
||||
ncpus_cmp_func, NULL);
|
||||
|
||||
/*
|
||||
* Allocate groups for each node according to the ratio of this
|
||||
* node's nr_cpus to remaining un-assigned ncpus. 'numgrps' is
|
||||
* bigger than number of active numa nodes. Always start the
|
||||
* allocation from the node with minimized nr_cpus.
|
||||
*
|
||||
* This way guarantees that each active node gets allocated at
|
||||
* least one group, and the theory is simple: over-allocation
|
||||
* is only done when this node is assigned by one group, so
|
||||
* other nodes will be allocated >= 1 groups, since 'numgrps' is
|
||||
* bigger than number of numa nodes.
|
||||
*
|
||||
* One perfect invariant is that number of allocated groups for
|
||||
* each node is <= CPU count of this node:
|
||||
*
|
||||
* 1) suppose there are two nodes: A and B
|
||||
* ncpu(X) is CPU count of node X
|
||||
* grps(X) is the group count allocated to node X via this
|
||||
* algorithm
|
||||
*
|
||||
* ncpu(A) <= ncpu(B)
|
||||
* ncpu(A) + ncpu(B) = N
|
||||
* grps(A) + grps(B) = G
|
||||
*
|
||||
* grps(A) = max(1, round_down(G * ncpu(A) / N))
|
||||
* grps(B) = G - grps(A)
|
||||
*
|
||||
* both N and G are integer, and 2 <= G <= N, suppose
|
||||
* G = N - delta, and 0 <= delta <= N - 2
|
||||
*
|
||||
* 2) obviously grps(A) <= ncpu(A) because:
|
||||
*
|
||||
* if grps(A) is 1, then grps(A) <= ncpu(A) given
|
||||
* ncpu(A) >= 1
|
||||
*
|
||||
* otherwise,
|
||||
* grps(A) <= G * ncpu(A) / N <= ncpu(A), given G <= N
|
||||
*
|
||||
* 3) prove how grps(B) <= ncpu(B):
|
||||
*
|
||||
* if round_down(G * ncpu(A) / N) == 0, vecs(B) won't be
|
||||
* over-allocated, so grps(B) <= ncpu(B),
|
||||
*
|
||||
* otherwise:
|
||||
*
|
||||
* grps(A) =
|
||||
* round_down(G * ncpu(A) / N) =
|
||||
* round_down((N - delta) * ncpu(A) / N) =
|
||||
* round_down((N * ncpu(A) - delta * ncpu(A)) / N) >=
|
||||
* round_down((N * ncpu(A) - delta * N) / N) =
|
||||
* cpu(A) - delta
|
||||
*
|
||||
* then:
|
||||
*
|
||||
* grps(A) - G >= ncpu(A) - delta - G
|
||||
* =>
|
||||
* G - grps(A) <= G + delta - ncpu(A)
|
||||
* =>
|
||||
* grps(B) <= N - ncpu(A)
|
||||
* =>
|
||||
* grps(B) <= cpu(B)
|
||||
*
|
||||
* For nodes >= 3, it can be thought as one node and another big
|
||||
* node given that is exactly what this algorithm is implemented,
|
||||
* and we always re-calculate 'remaining_ncpus' & 'numgrps', and
|
||||
* finally for each node X: grps(X) <= ncpu(X).
|
||||
*
|
||||
*/
|
||||
for (n = 0; n < nr_node_ids; n++) {
|
||||
unsigned ngroups, ncpus;
|
||||
|
||||
if (node_groups[n].ncpus == UINT_MAX)
|
||||
continue;
|
||||
|
||||
WARN_ON_ONCE(numgrps == 0);
|
||||
|
||||
ncpus = node_groups[n].ncpus;
|
||||
ngroups = max_t(unsigned, 1,
|
||||
numgrps * ncpus / remaining_ncpus);
|
||||
WARN_ON_ONCE(ngroups > ncpus);
|
||||
|
||||
node_groups[n].ngroups = ngroups;
|
||||
|
||||
remaining_ncpus -= ncpus;
|
||||
numgrps -= ngroups;
|
||||
}
|
||||
}
|
||||
|
||||
static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps,
|
||||
cpumask_var_t *node_to_cpumask,
|
||||
const struct cpumask *cpu_mask,
|
||||
struct cpumask *nmsk, struct cpumask *masks)
|
||||
{
|
||||
unsigned int i, n, nodes, cpus_per_grp, extra_grps, done = 0;
|
||||
unsigned int last_grp = numgrps;
|
||||
unsigned int curgrp = startgrp;
|
||||
nodemask_t nodemsk = NODE_MASK_NONE;
|
||||
struct node_groups *node_groups;
|
||||
|
||||
if (cpumask_empty(cpu_mask))
|
||||
return 0;
|
||||
|
||||
nodes = get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk);
|
||||
|
||||
/*
|
||||
* If the number of nodes in the mask is greater than or equal the
|
||||
* number of groups we just spread the groups across the nodes.
|
||||
*/
|
||||
if (numgrps <= nodes) {
|
||||
for_each_node_mask(n, nodemsk) {
|
||||
/* Ensure that only CPUs which are in both masks are set */
|
||||
cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]);
|
||||
cpumask_or(&masks[curgrp], &masks[curgrp], nmsk);
|
||||
if (++curgrp == last_grp)
|
||||
curgrp = 0;
|
||||
}
|
||||
return numgrps;
|
||||
}
|
||||
|
||||
node_groups = kcalloc(nr_node_ids,
|
||||
sizeof(struct node_groups),
|
||||
GFP_KERNEL);
|
||||
if (!node_groups)
|
||||
return -ENOMEM;
|
||||
|
||||
/* allocate group number for each node */
|
||||
alloc_nodes_groups(numgrps, node_to_cpumask, cpu_mask,
|
||||
nodemsk, nmsk, node_groups);
|
||||
for (i = 0; i < nr_node_ids; i++) {
|
||||
unsigned int ncpus, v;
|
||||
struct node_groups *nv = &node_groups[i];
|
||||
|
||||
if (nv->ngroups == UINT_MAX)
|
||||
continue;
|
||||
|
||||
/* Get the cpus on this node which are in the mask */
|
||||
cpumask_and(nmsk, cpu_mask, node_to_cpumask[nv->id]);
|
||||
ncpus = cpumask_weight(nmsk);
|
||||
if (!ncpus)
|
||||
continue;
|
||||
|
||||
WARN_ON_ONCE(nv->ngroups > ncpus);
|
||||
|
||||
/* Account for rounding errors */
|
||||
extra_grps = ncpus - nv->ngroups * (ncpus / nv->ngroups);
|
||||
|
||||
/* Spread allocated groups on CPUs of the current node */
|
||||
for (v = 0; v < nv->ngroups; v++, curgrp++) {
|
||||
cpus_per_grp = ncpus / nv->ngroups;
|
||||
|
||||
/* Account for extra groups to compensate rounding errors */
|
||||
if (extra_grps) {
|
||||
cpus_per_grp++;
|
||||
--extra_grps;
|
||||
}
|
||||
|
||||
/*
|
||||
* wrapping has to be considered given 'startgrp'
|
||||
* may start anywhere
|
||||
*/
|
||||
if (curgrp >= last_grp)
|
||||
curgrp = 0;
|
||||
grp_spread_init_one(&masks[curgrp], nmsk,
|
||||
cpus_per_grp);
|
||||
}
|
||||
done += nv->ngroups;
|
||||
}
|
||||
kfree(node_groups);
|
||||
return done;
|
||||
}
|
||||
|
||||
/**
|
||||
* group_cpus_evenly - Group all CPUs evenly per NUMA/CPU locality
|
||||
* @numgrps: number of groups
|
||||
*
|
||||
* Return: cpumask array if successful, NULL otherwise. And each element
|
||||
* includes CPUs assigned to this group
|
||||
*
|
||||
* Try to put close CPUs from viewpoint of CPU and NUMA locality into
|
||||
* same group, and run two-stage grouping:
|
||||
* 1) allocate present CPUs on these groups evenly first
|
||||
* 2) allocate other possible CPUs on these groups evenly
|
||||
*
|
||||
* We guarantee in the resulted grouping that all CPUs are covered, and
|
||||
* no same CPU is assigned to multiple groups
|
||||
*/
|
||||
struct cpumask *group_cpus_evenly(unsigned int numgrps)
|
||||
{
|
||||
unsigned int curgrp = 0, nr_present = 0, nr_others = 0;
|
||||
cpumask_var_t *node_to_cpumask;
|
||||
cpumask_var_t nmsk, npresmsk;
|
||||
int ret = -ENOMEM;
|
||||
struct cpumask *masks = NULL;
|
||||
|
||||
if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL))
|
||||
return NULL;
|
||||
|
||||
if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL))
|
||||
goto fail_nmsk;
|
||||
|
||||
node_to_cpumask = alloc_node_to_cpumask();
|
||||
if (!node_to_cpumask)
|
||||
goto fail_npresmsk;
|
||||
|
||||
masks = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
|
||||
if (!masks)
|
||||
goto fail_node_to_cpumask;
|
||||
|
||||
build_node_to_cpumask(node_to_cpumask);
|
||||
|
||||
/*
|
||||
* Make a local cache of 'cpu_present_mask', so the two stages
|
||||
* spread can observe consistent 'cpu_present_mask' without holding
|
||||
* cpu hotplug lock, then we can reduce deadlock risk with cpu
|
||||
* hotplug code.
|
||||
*
|
||||
* Here CPU hotplug may happen when reading `cpu_present_mask`, and
|
||||
* we can live with the case because it only affects that hotplug
|
||||
* CPU is handled in the 1st or 2nd stage, and either way is correct
|
||||
* from API user viewpoint since 2-stage spread is sort of
|
||||
* optimization.
|
||||
*/
|
||||
cpumask_copy(npresmsk, data_race(cpu_present_mask));
|
||||
|
||||
/* grouping present CPUs first */
|
||||
ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask,
|
||||
npresmsk, nmsk, masks);
|
||||
if (ret < 0)
|
||||
goto fail_build_affinity;
|
||||
nr_present = ret;
|
||||
|
||||
/*
|
||||
* Allocate non present CPUs starting from the next group to be
|
||||
* handled. If the grouping of present CPUs already exhausted the
|
||||
* group space, assign the non present CPUs to the already
|
||||
* allocated out groups.
|
||||
*/
|
||||
if (nr_present >= numgrps)
|
||||
curgrp = 0;
|
||||
else
|
||||
curgrp = nr_present;
|
||||
cpumask_andnot(npresmsk, cpu_possible_mask, npresmsk);
|
||||
ret = __group_cpus_evenly(curgrp, numgrps, node_to_cpumask,
|
||||
npresmsk, nmsk, masks);
|
||||
if (ret >= 0)
|
||||
nr_others = ret;
|
||||
|
||||
fail_build_affinity:
|
||||
if (ret >= 0)
|
||||
WARN_ON(nr_present + nr_others < numgrps);
|
||||
|
||||
fail_node_to_cpumask:
|
||||
free_node_to_cpumask(node_to_cpumask);
|
||||
|
||||
fail_npresmsk:
|
||||
free_cpumask_var(npresmsk);
|
||||
|
||||
fail_nmsk:
|
||||
free_cpumask_var(nmsk);
|
||||
if (ret < 0) {
|
||||
kfree(masks);
|
||||
return NULL;
|
||||
}
|
||||
return masks;
|
||||
}
|
||||
#else /* CONFIG_SMP */
|
||||
struct cpumask *group_cpus_evenly(unsigned int numgrps)
|
||||
{
|
||||
struct cpumask *masks = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
|
||||
|
||||
if (!masks)
|
||||
return NULL;
|
||||
|
||||
/* assign all CPUs(cpu 0) to the 1st group only */
|
||||
cpumask_copy(&masks[0], cpu_possible_mask);
|
||||
return masks;
|
||||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
@@ -508,7 +508,7 @@ void ida_free(struct ida *ida, unsigned int id)
|
||||
goto delete;
|
||||
xas_store(&xas, xa_mk_value(v));
|
||||
} else {
|
||||
if (!test_bit(bit, bitmap->bitmap))
|
||||
if (!bitmap || !test_bit(bit, bitmap->bitmap))
|
||||
goto err;
|
||||
__clear_bit(bit, bitmap->bitmap);
|
||||
xas_set_mark(&xas, XA_FREE_MARK);
|
||||
|
||||
@@ -52,12 +52,14 @@ static void debugfs_print_result(struct seq_file *seq,
|
||||
static int debugfs_print_results(struct seq_file *seq, void *v)
|
||||
{
|
||||
struct kunit_suite *suite = (struct kunit_suite *)seq->private;
|
||||
enum kunit_status success = kunit_suite_has_succeeded(suite);
|
||||
enum kunit_status success;
|
||||
struct kunit_case *test_case;
|
||||
|
||||
if (!suite)
|
||||
return 0;
|
||||
|
||||
success = kunit_suite_has_succeeded(suite);
|
||||
|
||||
/* Print KTAP header so the debugfs log can be parsed as valid KTAP. */
|
||||
seq_puts(seq, "KTAP version 1\n");
|
||||
seq_puts(seq, "1..1\n");
|
||||
|
||||
@@ -102,8 +102,10 @@ static void kunit_free_suite_set(struct suite_set suite_set)
|
||||
{
|
||||
struct kunit_suite * const *suites;
|
||||
|
||||
for (suites = suite_set.start; suites < suite_set.end; suites++)
|
||||
for (suites = suite_set.start; suites < suite_set.end; suites++) {
|
||||
kfree((*suites)->test_cases);
|
||||
kfree(*suites);
|
||||
}
|
||||
kfree(suite_set.start);
|
||||
}
|
||||
|
||||
|
||||
@@ -5913,7 +5913,7 @@ int mas_expected_entries(struct ma_state *mas, unsigned long nr_entries)
|
||||
/* Internal nodes */
|
||||
nr_nodes += DIV_ROUND_UP(nr_nodes, nonleaf_cap);
|
||||
/* Add working room for split (2 nodes) + new parents */
|
||||
mas_node_count(mas, nr_nodes + 3);
|
||||
mas_node_count_gfp(mas, nr_nodes + 3, GFP_KERNEL);
|
||||
|
||||
/* Detect if allocations run out */
|
||||
mas->mas_flags |= MA_STATE_PREALLOC;
|
||||
|
||||
@@ -30,7 +30,8 @@ static noinline u32 fprobe_selftest_target2(u32 value)
|
||||
return (value / div_factor) + 1;
|
||||
}
|
||||
|
||||
static notrace void fp_entry_handler(struct fprobe *fp, unsigned long ip, struct pt_regs *regs)
|
||||
static notrace void fp_entry_handler(struct fprobe *fp, unsigned long ip,
|
||||
struct pt_regs *regs, void *data)
|
||||
{
|
||||
KUNIT_EXPECT_FALSE(current_test, preemptible());
|
||||
/* This can be called on the fprobe_selftest_target and the fprobe_selftest_target2 */
|
||||
@@ -39,7 +40,8 @@ static notrace void fp_entry_handler(struct fprobe *fp, unsigned long ip, struct
|
||||
entry_val = (rand1 / div_factor);
|
||||
}
|
||||
|
||||
static notrace void fp_exit_handler(struct fprobe *fp, unsigned long ip, struct pt_regs *regs)
|
||||
static notrace void fp_exit_handler(struct fprobe *fp, unsigned long ip,
|
||||
struct pt_regs *regs, void *data)
|
||||
{
|
||||
unsigned long ret = regs_return_value(regs);
|
||||
|
||||
|
||||
@@ -150,6 +150,45 @@ static void ida_check_conv(struct ida *ida)
|
||||
IDA_BUG_ON(ida, !ida_is_empty(ida));
|
||||
}
|
||||
|
||||
/*
|
||||
* Check various situations where we attempt to free an ID we don't own.
|
||||
*/
|
||||
static void ida_check_bad_free(struct ida *ida)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
printk("vvv Ignore \"not allocated\" warnings\n");
|
||||
/* IDA is empty; all of these will fail */
|
||||
ida_free(ida, 0);
|
||||
for (i = 0; i < 31; i++)
|
||||
ida_free(ida, 1 << i);
|
||||
|
||||
/* IDA contains a single value entry */
|
||||
IDA_BUG_ON(ida, ida_alloc_min(ida, 3, GFP_KERNEL) != 3);
|
||||
ida_free(ida, 0);
|
||||
for (i = 0; i < 31; i++)
|
||||
ida_free(ida, 1 << i);
|
||||
|
||||
/* IDA contains a single bitmap */
|
||||
IDA_BUG_ON(ida, ida_alloc_min(ida, 1023, GFP_KERNEL) != 1023);
|
||||
ida_free(ida, 0);
|
||||
for (i = 0; i < 31; i++)
|
||||
ida_free(ida, 1 << i);
|
||||
|
||||
/* IDA contains a tree */
|
||||
IDA_BUG_ON(ida, ida_alloc_min(ida, (1 << 20) - 1, GFP_KERNEL) != (1 << 20) - 1);
|
||||
ida_free(ida, 0);
|
||||
for (i = 0; i < 31; i++)
|
||||
ida_free(ida, 1 << i);
|
||||
printk("^^^ \"not allocated\" warnings over\n");
|
||||
|
||||
ida_free(ida, 3);
|
||||
ida_free(ida, 1023);
|
||||
ida_free(ida, (1 << 20) - 1);
|
||||
|
||||
IDA_BUG_ON(ida, !ida_is_empty(ida));
|
||||
}
|
||||
|
||||
static DEFINE_IDA(ida);
|
||||
|
||||
static int ida_checks(void)
|
||||
@@ -162,6 +201,7 @@ static int ida_checks(void)
|
||||
ida_check_leaf(&ida, 1024 * 64);
|
||||
ida_check_max(&ida);
|
||||
ida_check_conv(&ida);
|
||||
ida_check_bad_free(&ida);
|
||||
|
||||
printk("IDA: %u of %u tests passed\n", tests_passed, tests_run);
|
||||
return (tests_run != tests_passed) ? 0 : -EINVAL;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <linux/maple_tree.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/rwsem.h>
|
||||
|
||||
#define MTREE_ALLOC_MAX 0x2000000000000Ul
|
||||
#ifndef CONFIG_DEBUG_MAPLE_TREE
|
||||
@@ -1678,17 +1679,21 @@ static noinline void __init check_forking(struct maple_tree *mt)
|
||||
void *val;
|
||||
MA_STATE(mas, mt, 0, 0);
|
||||
MA_STATE(newmas, mt, 0, 0);
|
||||
struct rw_semaphore newmt_lock;
|
||||
|
||||
init_rwsem(&newmt_lock);
|
||||
|
||||
for (i = 0; i <= nr_entries; i++)
|
||||
mtree_store_range(mt, i*10, i*10 + 5,
|
||||
xa_mk_value(i), GFP_KERNEL);
|
||||
|
||||
mt_set_non_kernel(99999);
|
||||
mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE);
|
||||
mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN);
|
||||
mt_set_external_lock(&newmt, &newmt_lock);
|
||||
newmas.tree = &newmt;
|
||||
mas_reset(&newmas);
|
||||
mas_reset(&mas);
|
||||
mas_lock(&newmas);
|
||||
down_write(&newmt_lock);
|
||||
mas.index = 0;
|
||||
mas.last = 0;
|
||||
if (mas_expected_entries(&newmas, nr_entries)) {
|
||||
@@ -1703,10 +1708,10 @@ static noinline void __init check_forking(struct maple_tree *mt)
|
||||
}
|
||||
rcu_read_unlock();
|
||||
mas_destroy(&newmas);
|
||||
mas_unlock(&newmas);
|
||||
mt_validate(&newmt);
|
||||
mt_set_non_kernel(0);
|
||||
mtree_destroy(&newmt);
|
||||
__mt_destroy(&newmt);
|
||||
up_write(&newmt_lock);
|
||||
}
|
||||
|
||||
static noinline void __init check_iteration(struct maple_tree *mt)
|
||||
@@ -1818,6 +1823,10 @@ static noinline void __init bench_forking(struct maple_tree *mt)
|
||||
void *val;
|
||||
MA_STATE(mas, mt, 0, 0);
|
||||
MA_STATE(newmas, mt, 0, 0);
|
||||
struct rw_semaphore newmt_lock;
|
||||
|
||||
init_rwsem(&newmt_lock);
|
||||
mt_set_external_lock(&newmt, &newmt_lock);
|
||||
|
||||
for (i = 0; i <= nr_entries; i++)
|
||||
mtree_store_range(mt, i*10, i*10 + 5,
|
||||
@@ -1832,7 +1841,7 @@ static noinline void __init bench_forking(struct maple_tree *mt)
|
||||
mas.index = 0;
|
||||
mas.last = 0;
|
||||
rcu_read_lock();
|
||||
mas_lock(&newmas);
|
||||
down_write(&newmt_lock);
|
||||
if (mas_expected_entries(&newmas, nr_entries)) {
|
||||
printk("OOM!");
|
||||
BUG_ON(1);
|
||||
@@ -1843,11 +1852,11 @@ static noinline void __init bench_forking(struct maple_tree *mt)
|
||||
mas_store(&newmas, val);
|
||||
}
|
||||
mas_destroy(&newmas);
|
||||
mas_unlock(&newmas);
|
||||
rcu_read_unlock();
|
||||
mt_validate(&newmt);
|
||||
mt_set_non_kernel(0);
|
||||
mtree_destroy(&newmt);
|
||||
__mt_destroy(&newmt);
|
||||
up_write(&newmt_lock);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2453,6 +2462,10 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
|
||||
void *tmp;
|
||||
MA_STATE(mas, mt, 0, 0);
|
||||
MA_STATE(newmas, &newmt, 0, 0);
|
||||
struct rw_semaphore newmt_lock;
|
||||
|
||||
init_rwsem(&newmt_lock);
|
||||
mt_set_external_lock(&newmt, &newmt_lock);
|
||||
|
||||
if (!zero_start)
|
||||
i = 1;
|
||||
@@ -2462,9 +2475,9 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
|
||||
mtree_store_range(mt, i*10, (i+1)*10 - gap,
|
||||
xa_mk_value(i), GFP_KERNEL);
|
||||
|
||||
mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE);
|
||||
mt_init_flags(&newmt, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_LOCK_EXTERN);
|
||||
mt_set_non_kernel(99999);
|
||||
mas_lock(&newmas);
|
||||
down_write(&newmt_lock);
|
||||
ret = mas_expected_entries(&newmas, nr_entries);
|
||||
mt_set_non_kernel(0);
|
||||
MT_BUG_ON(mt, ret != 0);
|
||||
@@ -2477,9 +2490,9 @@ static noinline void __init check_dup_gaps(struct maple_tree *mt,
|
||||
}
|
||||
rcu_read_unlock();
|
||||
mas_destroy(&newmas);
|
||||
mas_unlock(&newmas);
|
||||
|
||||
mtree_destroy(&newmt);
|
||||
__mt_destroy(&newmt);
|
||||
up_write(&newmt_lock);
|
||||
}
|
||||
|
||||
/* Duplicate many sizes of trees. Mainly to test expected entry values */
|
||||
|
||||
@@ -93,7 +93,7 @@ static int __init test_pages(int *total_failures)
|
||||
int failures = 0, num_tests = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= MAX_ORDER; i++)
|
||||
for (i = 0; i < MAX_ORDER; i++)
|
||||
num_tests += do_alloc_pages_order(i, &failures);
|
||||
|
||||
REPORT_FAILURES_IN_FN();
|
||||
|
||||
@@ -2092,15 +2092,20 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf,
|
||||
|
||||
/* Loop starting from the root node to the current node. */
|
||||
for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) {
|
||||
struct fwnode_handle *__fwnode =
|
||||
fwnode_get_nth_parent(fwnode, depth);
|
||||
/*
|
||||
* Only get a reference for other nodes (i.e. parent nodes).
|
||||
* fwnode refcount may be 0 here.
|
||||
*/
|
||||
struct fwnode_handle *__fwnode = depth ?
|
||||
fwnode_get_nth_parent(fwnode, depth) : fwnode;
|
||||
|
||||
buf = string(buf, end, fwnode_get_name_prefix(__fwnode),
|
||||
default_str_spec);
|
||||
buf = string(buf, end, fwnode_get_name(__fwnode),
|
||||
default_str_spec);
|
||||
|
||||
fwnode_handle_put(__fwnode);
|
||||
if (depth)
|
||||
fwnode_handle_put(__fwnode);
|
||||
}
|
||||
|
||||
return buf;
|
||||
|
||||
@@ -312,7 +312,7 @@ size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size
|
||||
|
||||
typedef struct {
|
||||
short ncount[FSE_MAX_SYMBOL_VALUE + 1];
|
||||
FSE_DTable dtable[1]; /* Dynamically sized */
|
||||
FSE_DTable dtable[]; /* Dynamically sized */
|
||||
} FSE_DecompressWksp;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user