05 Dec, 2019
40 commits
-
Userspace cannot compile due to some missing type
definitions. For example, building it for x86 fails as follows:CC usr/include/asm/msgbuf.h.s
In file included from usr/include/asm/msgbuf.h:6:0,
from :32:
usr/include/asm-generic/msgbuf.h:25:20: error: field `msg_perm' has incomplete type
struct ipc64_perm msg_perm;
^~~~~~~~
usr/include/asm-generic/msgbuf.h:27:2: error: unknown type name `__kernel_time_t'
__kernel_time_t msg_stime; /* last msgsnd time */
^~~~~~~~~~~~~~~
usr/include/asm-generic/msgbuf.h:28:2: error: unknown type name `__kernel_time_t'
__kernel_time_t msg_rtime; /* last msgrcv time */
^~~~~~~~~~~~~~~
usr/include/asm-generic/msgbuf.h:29:2: error: unknown type name `__kernel_time_t'
__kernel_time_t msg_ctime; /* last change time */
^~~~~~~~~~~~~~~
usr/include/asm-generic/msgbuf.h:41:2: error: unknown type name `__kernel_pid_t'
__kernel_pid_t msg_lspid; /* pid of last msgsnd */
^~~~~~~~~~~~~~
usr/include/asm-generic/msgbuf.h:42:2: error: unknown type name `__kernel_pid_t'
__kernel_pid_t msg_lrpid; /* last receive pid */
^~~~~~~~~~~~~~It is just a matter of missing include directive.
Include to make it self-contained, and add it to
the compile-test coverage.Link: http://lkml.kernel.org/r/20191030063855.9989-2-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada
Cc: Arnd Bergmann
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Userspace cannot compile due to some missing type
definitions. For example, building it for x86 fails as follows:CC usr/include/asm/ipcbuf.h.s
In file included from usr/include/asm/ipcbuf.h:1:0,
from :32:
usr/include/asm-generic/ipcbuf.h:21:2: error: unknown type name `__kernel_key_t'
__kernel_key_t key;
^~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:22:2: error: unknown type name `__kernel_uid32_t'
__kernel_uid32_t uid;
^~~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:23:2: error: unknown type name `__kernel_gid32_t'
__kernel_gid32_t gid;
^~~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:24:2: error: unknown type name `__kernel_uid32_t'
__kernel_uid32_t cuid;
^~~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:25:2: error: unknown type name `__kernel_gid32_t'
__kernel_gid32_t cgid;
^~~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:26:2: error: unknown type name `__kernel_mode_t'
__kernel_mode_t mode;
^~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:28:35: error: `__kernel_mode_t' undeclared here (not in a function)
unsigned char __pad1[4 - sizeof(__kernel_mode_t)];
^~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:31:2: error: unknown type name `__kernel_ulong_t'
__kernel_ulong_t __unused1;
^~~~~~~~~~~~~~~~
usr/include/asm-generic/ipcbuf.h:32:2: error: unknown type name `__kernel_ulong_t'
__kernel_ulong_t __unused2;
^~~~~~~~~~~~~~~~It is just a matter of missing include directive.
Include to make it self-contained, and add it to
the compile-test coverage.Link: http://lkml.kernel.org/r/20191030063855.9989-1-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada
Cc: Arnd Bergmann
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
At the moment, UBSAN report will be serialized using a spin_lock(). On
RT-systems, spinlocks are turned to rt_spin_lock and may sleep. This
will result to the following splat if the undefined behavior is in a
context that can sleep:BUG: sleeping function called from invalid context at /src/linux/kernel/locking/rtmutex.c:968
in_atomic(): 1, irqs_disabled(): 128, pid: 3447, name: make
1 lock held by make/3447:
#0: 000000009a966332 (&mm->mmap_sem){++++}, at: do_page_fault+0x140/0x4f8
irq event stamp: 6284
hardirqs last enabled at (6283): [] _raw_spin_unlock_irqrestore+0x90/0xa0
hardirqs last disabled at (6284): [] _raw_spin_lock_irqsave+0x30/0x78
softirqs last enabled at (2430): [] fpsimd_restore_current_state+0x60/0xe8
softirqs last disabled at (2427): [] fpsimd_restore_current_state+0x28/0xe8
Preemption disabled at:
[] rt_mutex_futex_unlock+0x4c/0xb0
CPU: 3 PID: 3447 Comm: make Tainted: G W 5.2.14-rt7-01890-ge6e057589653 #911
Call trace:
dump_backtrace+0x0/0x148
show_stack+0x14/0x20
dump_stack+0xbc/0x104
___might_sleep+0x154/0x210
rt_spin_lock+0x68/0xa0
ubsan_prologue+0x30/0x68
handle_overflow+0x64/0xe0
__ubsan_handle_add_overflow+0x10/0x18
__lock_acquire+0x1c28/0x2a28
lock_acquire+0xf0/0x370
_raw_spin_lock_irqsave+0x58/0x78
rt_mutex_futex_unlock+0x4c/0xb0
rt_spin_unlock+0x28/0x70
get_page_from_freelist+0x428/0x2b60
__alloc_pages_nodemask+0x174/0x1708
alloc_pages_vma+0x1ac/0x238
__handle_mm_fault+0x4ac/0x10b0
handle_mm_fault+0x1d8/0x3b0
do_page_fault+0x1c8/0x4f8
do_translation_fault+0xb8/0xe0
do_mem_abort+0x3c/0x98
el0_da+0x20/0x24The spin_lock() will protect against multiple CPUs to output a report
together, I guess to prevent them from being interleaved. However, they
can still interleave with other messages (and even splat from
__might_sleep).So the lock usefulness seems pretty limited. Rather than trying to
accomodate RT-system by switching to a raw_spin_lock(), the lock is now
completely dropped.Link: http://lkml.kernel.org/r/20190920100835.14999-1-julien.grall@arm.com
Signed-off-by: Julien Grall
Reported-by: Andre Przywara
Acked-by: Andrey Ryabinin
Cc: Thomas Gleixner
Cc: Sebastian Andrzej Siewior
Cc: Steven Rostedt
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Add kcov_remote_start()/kcov_remote_stop() annotations to the
vhost_worker() function, which is responsible for processing vhost
works.Since vhost_worker() threads are spawned per vhost device instance the
common kcov handle is used for kcov_remote_start()/stop() annotations
(see Documentation/dev-tools/kcov.rst for details). As the result kcov
can now be used to collect coverage from vhost worker threads.Link: http://lkml.kernel.org/r/e49d5d154e5da6c9ada521d2b7ce10a49ce9f98b.1572366574.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov
Cc: Alan Stern
Cc: Alexander Potapenko
Cc: Anders Roxell
Cc: Arnd Bergmann
Cc: David Windsor
Cc: Dmitry Vyukov
Cc: Elena Reshetova
Cc: Greg Kroah-Hartman
Cc: Jason Wang
Cc: Marco Elver
Cc: "Michael S. Tsirkin"
Cc: Steven Rostedt
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Add kcov_remote_start()/kcov_remote_stop() annotations to the
hub_event() function, which is responsible for processing events on USB
buses, in particular events that happen during USB device enumeration.Since hub_event() is run in a global background kernel thread (see
Documentation/dev-tools/kcov.rst for details), each USB bus gets a
unique global handle from the USB subsystem kcov handle range. As the
result kcov can now be used to collect coverage from events that happen
on a particular USB bus.[akpm@linux-foundation.org: avoid patch conflicts to make life easier for Andrew]
Link: http://lkml.kernel.org/r/de4fe1c219db2d002d905dc1736e2a3bfa1db997.1572366574.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov
Reviewed-by: Greg Kroah-Hartman
Cc: Alan Stern
Cc: Alexander Potapenko
Cc: Anders Roxell
Cc: Arnd Bergmann
Cc: David Windsor
Cc: Dmitry Vyukov
Cc: Elena Reshetova
Cc: Jason Wang
Cc: Marco Elver
Cc: "Michael S. Tsirkin"
Cc: Steven Rostedt
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Patch series " kcov: collect coverage from usb and vhost", v3.
This patchset extends kcov to allow collecting coverage from backgound
kernel threads. This extension requires custom annotations for each of
the places where coverage collection is desired. This patchset
implements this for hub events in the USB subsystem and for vhost
workers. See the first patch description for details about the kcov
extension. The other two patches apply this kcov extension to USB and
vhost.Examples of other subsystems that might potentially benefit from this
when custom annotations are added (the list is based on
process_one_work() callers for bugs recently reported by syzbot):1. fs: writeback wb_workfn() worker,
2. net: addrconf_dad_work()/addrconf_verify_work() workers,
3. net: neigh_periodic_work() worker,
4. net/p9: p9_write_work()/p9_read_work() workers,
5. block: blk_mq_run_work_fn() worker.These patches have been used to enable coverage-guided USB fuzzing with
syzkaller for the last few years, see the details here:https://github.com/google/syzkaller/blob/master/docs/linux/external_fuzzing_usb.md
This patchset has been pushed to the public Linux kernel Gerrit
instance:https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/1524
This patch (of 3):
Add background thread coverage collection ability to kcov.
With KCOV_ENABLE coverage is collected only for syscalls that are issued
from the current process. With KCOV_REMOTE_ENABLE it's possible to
collect coverage for arbitrary parts of the kernel code, provided that
those parts are annotated with kcov_remote_start()/kcov_remote_stop().This allows to collect coverage from two types of kernel background
threads: the global ones, that are spawned during kernel boot in a
limited number of instances (e.g. one USB hub_event() worker thread is
spawned per USB HCD); and the local ones, that are spawned when a user
interacts with some kernel interface (e.g. vhost workers).To enable collecting coverage from a global background thread, a unique
global handle must be assigned and passed to the corresponding
kcov_remote_start() call. Then a userspace process can pass a list of
such handles to the KCOV_REMOTE_ENABLE ioctl in the handles array field
of the kcov_remote_arg struct. This will attach the used kcov device to
the code sections, that are referenced by those handles.Since there might be many local background threads spawned from
different userspace processes, we can't use a single global handle per
annotation. Instead, the userspace process passes a non-zero handle
through the common_handle field of the kcov_remote_arg struct. This
common handle gets saved to the kcov_handle field in the current
task_struct and needs to be passed to the newly spawned threads via
custom annotations. Those threads should in turn be annotated with
kcov_remote_start()/kcov_remote_stop().Internally kcov stores handles as u64 integers. The top byte of a
handle is used to denote the id of a subsystem that this handle belongs
to, and the lower 4 bytes are used to denote the id of a thread instance
within that subsystem. A reserved value 0 is used as a subsystem id for
common handles as they don't belong to a particular subsystem. The
bytes 4-7 are currently reserved and must be zero. In the future the
number of bytes used for the subsystem or handle ids might be increased.When a particular userspace process collects coverage by via a common
handle, kcov will collect coverage for each code section that is
annotated to use the common handle obtained as kcov_handle from the
current task_struct. However non common handles allow to collect
coverage selectively from different subsystems.Link: http://lkml.kernel.org/r/e90e315426a384207edbec1d6aa89e43008e4caf.1572366574.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov
Cc: Dmitry Vyukov
Cc: Greg Kroah-Hartman
Cc: Alan Stern
Cc: "Michael S. Tsirkin"
Cc: Jason Wang
Cc: Arnd Bergmann
Cc: Steven Rostedt
Cc: David Windsor
Cc: Elena Reshetova
Cc: Anders Roxell
Cc: Alexander Potapenko
Cc: Marco Elver
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
As we've done with VFS, string operations, etc, reject usercopy sizes
larger than INT_MAX, which would be nice to have for catching bugs
related to size calculation overflows[1].This adds 10 bytes to x86_64 defconfig text and 1980 bytes to the data
section:text data bss dec hex filename
19691167 5134320 1646664 26472151 193eed7 vmlinux.before
19691177 5136300 1646664 26474141 193f69d vmlinux.after[1] https://marc.info/?l=linux-s390&m=156631939010493&w=2
Link: http://lkml.kernel.org/r/201908251612.F9902D7A@keescook
Signed-off-by: Kees Cook
Suggested-by: Dan Carpenter
Cc: Alexander Viro
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
The hardened usercpy code is too paranoid ever since commit 6a30afa8c1fb
("uaccess: disallow > INT_MAX copy sizes")Code itself should have been fine as-is.
Link: http://lkml.kernel.org/r/20191106164755.31478-1-daniel.vetter@ffwll.ch
Signed-off-by: Daniel Vetter
Reported-by: syzbot+fb77e97ebf0612ee6914@syzkaller.appspotmail.com
Fixes: 6a30afa8c1fb ("uaccess: disallow > INT_MAX copy sizes")
Cc: Kees Cook
Cc: Alexander Viro
Cc: Stephen Rothwell
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Include for the missing declarations of functions
exported from this file. Fixes the following sparse warnings:drivers/rapidio/rio-access.c:59:1: warning: symbol '__rio_local_read_config_8' was not declared. Should it be static?
drivers/rapidio/rio-access.c:60:1: warning: symbol '__rio_local_read_config_16' was not declared. Should it be static?
drivers/rapidio/rio-access.c:61:1: warning: symbol '__rio_local_read_config_32' was not declared. Should it be static?
drivers/rapidio/rio-access.c:62:1: warning: symbol '__rio_local_write_config_8' was not declared. Should it be static?
drivers/rapidio/rio-access.c:63:1: warning: symbol '__rio_local_write_config_16' was not declared. Should it be static?
drivers/rapidio/rio-access.c:64:1: warning: symbol '__rio_local_write_config_32' was not declared. Should it be static?
drivers/rapidio/rio-access.c:112:1: warning: symbol 'rio_mport_read_config_8' was not declared. Should it be static?
drivers/rapidio/rio-access.c:113:1: warning: symbol 'rio_mport_read_config_16' was not declared. Should it be static?
drivers/rapidio/rio-access.c:114:1: warning: symbol 'rio_mport_read_config_32' was not declared. Should it be static?
drivers/rapidio/rio-access.c:115:1: warning: symbol 'rio_mport_write_config_8' was not declared. Should it be static?
drivers/rapidio/rio-access.c:116:1: warning: symbol 'rio_mport_write_config_16' was not declared. Should it be static?
drivers/rapidio/rio-access.c:117:1: warning: symbol 'rio_mport_write_config_32' was not declared. Should it be static?
drivers/rapidio/rio-access.c:136:5: warning: symbol 'rio_mport_send_doorbell' was not declared. Should it be static?Link: http://lkml.kernel.org/r/20191017115103.684-1-ben.dooks@codethink.co.uk
Signed-off-by: Ben Dooks
Cc: Matt Porter
Cc: Alexandre Bounine
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Include for the missing declarations of functions
exported from this file. Fixes the following sparse warnings:drivers/rapidio/rio-driver.c:53:16: warning: symbol 'rio_dev_get' was not declared. Should it be static?
drivers/rapidio/rio-driver.c:70:6: warning: symbol 'rio_dev_put' was not declared. Should it be static?
drivers/rapidio/rio-driver.c:150:5: warning: symbol 'rio_register_driver' was not declared. Should it be static?
drivers/rapidio/rio-driver.c:169:6: warning: symbol 'rio_unregister_driver' was not declared. Should it be static?Link: http://lkml.kernel.org/r/20191017114923.10888-1-ben.dooks@codethink.co.uk
Signed-off-by: Ben Dooks
Cc: Matt Porter
Cc: Alexandre Bounine
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Adjust indentation from spaces to tab (+optional two spaces) as in
coding style with command like:
$ sed -e 's/^ / /' -i */KconfigLink: http://lkml.kernel.org/r/1574306670-30234-1-git-send-email-krzk@kernel.org
Signed-off-by: Krzysztof Kozlowski
Cc: Jiri Kosina
Cc: Masahiro Yamada
Cc: Greg Kroah-Hartman
Cc: David Hildenbrand
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
ELF reads done by the kernel have very complicated error detection code
which better live in one place.Link: http://lkml.kernel.org/r/20191005165215.GB26927@avx2
Signed-off-by: Alexey Dobriyan
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Link: http://lkml.kernel.org/r/20191005165049.GA26927@avx2
Signed-off-by: Alexey Dobriyan
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
This adds the promised selftest for epoll. It will verify the wakeups
of epoll. Including leaf and nested mode, epoll_wait() and poll() and
multi-threads.Link: http://lkml.kernel.org/r/20191009121518.4027-1-r@hev.cc
Signed-off-by: hev
Reviewed-by: Roman Penyaev
Cc: Jason Baron
Cc: Shuah Khan
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Take the case where we have:
t0
| (ew)
e0
| (et)
e1
| (lt)
s0t0: thread 0
e0: epoll fd 0
e1: epoll fd 1
s0: socket fd 0
ew: epoll_wait
et: edge-trigger
lt: level-triggerWe remove unnecessary wakeups to prevent the nested epoll that working in edge-
triggered mode to waking up continuously.Test code:
#include
#include
#includeint main(int argc, char *argv[])
{
int sfd[2];
int efd[2];
struct epoll_event e;if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0)
goto out;efd[0] = epoll_create(1);
if (efd[0] < 0)
goto out;efd[1] = epoll_create(1);
if (efd[1] < 0)
goto out;e.events = EPOLLIN;
if (epoll_ctl(efd[1], EPOLL_CTL_ADD, sfd[0], &e) < 0)
goto out;e.events = EPOLLIN | EPOLLET;
if (epoll_ctl(efd[0], EPOLL_CTL_ADD, efd[1], &e) < 0)
goto out;if (write(sfd[1], "w", 1) != 1)
goto out;if (epoll_wait(efd[0], &e, 1, 0) != 1)
goto out;if (epoll_wait(efd[0], &e, 1, 0) != 0)
goto out;close(efd[0]);
close(efd[1]);
close(sfd[0]);
close(sfd[1]);return 0;
out:
return -1;
}More tests:
https://github.com/heiher/epoll-wakeupLink: http://lkml.kernel.org/r/20191009060516.3577-1-r@hev.cc
Signed-off-by: hev
Reviewed-by: Roman Penyaev
Cc: Al Viro
Cc: Davide Libenzi
Cc: Davidlohr Bueso
Cc: Dominik Brodowski
Cc: Eric Wong
Cc: Jason Baron
Cc: Sridhar Samudrala
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Currently, ep_poll_safewake() in the CONFIG_DEBUG_LOCK_ALLOC case uses
ep_call_nested() in order to pass the correct subclass argument to
spin_lock_irqsave_nested(). However, ep_call_nested() adds unnecessary
checks for epoll depth and loops that are already verified when doing
EPOLL_CTL_ADD. This mirrors a conversion that was done for
!CONFIG_DEBUG_LOCK_ALLOC in: commit 37b5e5212a44 ("epoll: remove
ep_call_nested() from ep_eventpoll_poll()")Link: http://lkml.kernel.org/r/1567628549-11501-1-git-send-email-jbaron@akamai.com
Signed-off-by: Jason Baron
Reviewed-by: Roman Penyaev
Cc: Davidlohr Bueso
Cc: Al Viro
Cc: Eric Wong
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
The is_maintained_obsolete function can be called twice using the same
filename. This function spawns a process using get_maintainer.pl.
Store the status of each filename when spawned and use the stored result
to eliminate the spawning of unnecessary duplicate child processes.Example:
old:
$ time ./scripts/checkpatch.pl hp100-Move-to-staging.patch > /dev/null
real 0m1.767s
user 0m1.634s
sys 0m0.141snew:
$ time ./scripts/checkpatch.pl hp100-Move-to-staging.patch > /dev/null
real 0m1.184s
user 0m1.085s
sys 0m0.103sLink: http://lkml.kernel.org/r/b982566a2b9b4825badce36fdfc3032bd0005151.camel@perches.com
Signed-off-by: Joe Perches
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Ignore all upper-case variants before and after SI units like mA, mV and
uV so uses like RANGE_mA do not emit a CAMELCASE message.Link: http://lkml.kernel.org/r/5ce6f9131327fd2e12d7a0e20a55f588448de090.camel@perches.com
Signed-off-by: Joe Perches
Cc: Jules Irenge
Cc: Al Viro
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Follow the kernel conventions, rename addr_in_gen_pool to
gen_pool_has_addr.[sjhuang@iluvatar.ai: fix Documentation/ too]
Link: http://lkml.kernel.org/r/20181229015914.5573-1-sjhuang@iluvatar.ai
Link: http://lkml.kernel.org/r/20181228083950.20398-1-sjhuang@iluvatar.ai
Signed-off-by: Huang Shijie
Reviewed-by: Andrew Morton
Cc: Russell King
Cc: Arnd Bergmann
Cc: Greg Kroah-Hartman
Cc: Christoph Hellwig
Cc: Marek Szyprowski
Cc: Robin Murphy
Cc: Stephen Rothwell
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
We use addr_in_gen_pool() in a driver module. So export it.
Link: http://lkml.kernel.org/r/20181224070622.22197-2-sjhuang@iluvatar.ai
Signed-off-by: Huang Shijie
Reviewed-by: Andrew Morton
Cc: Alexey Skidanov
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
In some cases the previous algorithm would not return the closest
approximation. This would happen when a semi-convergent was the
closest, as the previous algorithm would only consider convergents.As an example, consider an initial value of 5/4, and trying to find the
closest approximation with a maximum of 4 for numerator and denominator.
The previous algorithm would return 1/1 as the closest approximation,
while this version will return the correct answer of 4/3.To do this, the main loop performs effectively the same operations as it
did before. It must now keep track of the last three approximations,
n2/d2 .. n0/d0, while before it only needed the last two.If an exact answer is not found, the algorithm will now calculate the
best semi-convergent term, t, which is a single expression with two
divisions:min((max_numerator - n0) / n1, (max_denominator - d0) / d1)
This will be used if it is better than previous convergent. The test
for this is generally a simple comparison, 2*t > a. But in an edge
case, where the convergent's final term is even and the best allowable
semi-convergent has a final term of exactly half the convergent's final
term, the more complex comparison (d0*dp > d1*d) is used.I also wrote some comments explaining the code. While one still needs
to look up the math elsewhere, they should help a lot to follow how the
code relates to that math.This routine is used in two places in the video4linux code, but in those
cases it is only used to reduce a fraction to lowest terms, which the
existing code will do correctly. This could be done more efficiently
with a different library routine but it would still be the Euclidean
alogrithm at its heart. So no change.The remain users are places where a fractional PLL divider is
programmed. What would happen is something asked for a clock of X MHz
but instead gets Y MHz, where Y is close to X but not exactly due to the
hardware limitations. After this change they might, in some cases, get
Y' MHz, where Y' is a little closer to X then Y was.Users like this are: Three UARTs, in 8250_mid, 8250_lpss, and imx. One
GPU in vp4_hdmi. And three clock drivers, clk-cdce706, clk-si5351, and
clk-fractional-divider. The last is a generic clock driver and so would
have more users referenced via device tree entries.I think there's a bug in that one, it's limiting an N bit field that is
offset-by-1 to the range 0 .. (1<<
Cc: Oskar Schirmer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
kmem_cache_alloc_bulk/kmem_cache_free_bulk are used to make multiple
allocations of the same size to avoid the overhead of multiple
kmalloc/kfree calls. Extend the kmem_cache tests to make some calls to
these APIs.Link: http://lkml.kernel.org/r/20191107191447.23058-1-labbott@redhat.com
Signed-off-by: Laura Abbott
Reviewed-by: Kees Cook
Tested-by: Alexander Potapenko
Cc: Laura Abbott
Cc: Christoph Lameter
Cc: Nick Desaulniers
Cc: Kostya Serebryany
Cc: Dmitry Vyukov
Cc: Sandeep Patil
Cc: Jann Horn
Cc: Marco Elver
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
After move parent assignment out, we can check the color directly.
Link: http://lkml.kernel.org/r/20191028021442.5450-2-richardw.yang@linux.intel.com
Signed-off-by: Wei Yang
Acked-by: Peter Zijlstra (Intel)
Reviewed-by: Michel Lespinasse
Reviewed-by: Davidlohr Bueso
Cc: Thomas Gleixner
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Both in Case 2 and 3, we exchange n and s. This mean no matter whether
child2 is NULL or not, successor's parent should be assigned to node's.This patch takes this step out to make it explicit and reduce the
ambiguity.Besides, this step reduces some symbol size like rb_erase().
KERN_CONFIG upstream patched
OPT_FOR_PERF 877 870
OPT_FOR_SIZE 635 621Link: http://lkml.kernel.org/r/20191028021442.5450-1-richardw.yang@linux.intel.com
Signed-off-by: Wei Yang
Acked-by: Peter Zijlstra (Intel)
Reviewed-by: Michel Lespinasse
Reviewed-by: Davidlohr Bueso
Cc: Thomas Gleixner
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in set_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/3543ffc3668ad4ed4c00e8ebaf14a5559fd6ddf2.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Tested-by: Andy Shevchenko
Cc: Phil Reid
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/c2b1ed62caf6fce6e5681809a50c05ce6acdf2a6.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Cc: Andy Shevchenko
Cc: Mathias Duckeck
Cc: Lukas Wunner
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Masahiro Yamada
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/8a39ee772247d4b7d752b32dbacc06c1cdcb60b5.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Cc: Andy Shevchenko
Cc: Morten Hein Tiljeset
Cc: Sean Nyekjaer
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Phil Reid
Cc: Rasmus Villemoes
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Utilize for_each_set_clump8 macro, and the bitmap_set_value8 and
bitmap_get_value8 functions, where appropriate. In addition, remove the
now unnecessary temp_mask and temp_shift members of the
intel_soc_dts_sensor_entry structure.Link: http://lkml.kernel.org/r/2d3c74e9a00a52954f31d19e04623a7f4bc85520.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Suggested-by: Andy Shevchenko
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in set_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/7ea2df7182a50a1136ca36edc46dffcb2446fd27.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Suggested-by: Andy Shevchenko
Tested-by: Andy Shevchenko
Cc: Geert Uytterhoeven
Cc: Phil Reid
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in set_multiple callback with
for_each_set_clump8 macro to simplify code and improve clarity. An
improvement in this case is that banks that are not masked will now be
skipped.Link: http://lkml.kernel.org/r/5b24887e97f3093e4832d7c50a1093f537e91ab4.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Cc: Andy Shevchenko
Cc: Masahiro Yamada
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Linus Walleij
Cc: Lukas Wunner
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/d5d22fa9809dcf8330f4381dbe7e7ca37990e79f.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/b30f131b4634caf5a70f12e01496f71631a17305.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/7a0d2c964e7f2d289b16c63ff6b06fc1f4c50d4d.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/0de53d7021b2d6db10294473cd8a1b6102bcec94.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/b0631b6d489f85008480399df283ccd33ecfe310.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Replace verbose implementation in get_multiple/set_multiple callbacks
with for_each_set_clump8 macro to simplify code and improve clarity.Link: http://lkml.kernel.org/r/08b9c9a3e75ef1ab0d172223d10a1661f2b43fe2.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Linus Walleij
Cc: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Rasmus Villemoes
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
The introduction of the for_each_set_clump8 macro warrants test cases to
verify the implementation. This patch adds test case checks for whether
an out-of-bounds clump index is returned, a zero clump is returned, or
the returned clump value differs from the expected clump value.Link: http://lkml.kernel.org/r/febc0fb8151e3e3fdd61c34da9193d1c4d7e6c12.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Reviewed-by: Andy Shevchenko
Reviewed-by: Linus Walleij
Tested-by: Andy Shevchenko
Cc: Rasmus Villemoes
Cc: Arnd Bergmann
Cc: Bartosz Golaszewski
Cc: Geert Uytterhoeven
Cc: Geert Uytterhoeven
Cc: Lukas Wunner
Cc: Masahiro Yamada
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Phil Reid
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Pach series "Introduce the for_each_set_clump8 macro", v18.
While adding GPIO get_multiple/set_multiple callback support for various
drivers, I noticed a pattern of looping manifesting that would be useful
standardized as a macro.This patchset introduces the for_each_set_clump8 macro and utilizes it
in several GPIO drivers. The for_each_set_clump macro8 facilitates a
for-loop syntax that iterates over a memory region entire groups of set
bits at a time.For example, suppose you would like to iterate over a 32-bit integer 8
bits at a time, skipping over 8-bit groups with no set bit, where
XXXXXXXX represents the current 8-bit group:Example: 10111110 00000000 11111111 00110011
First loop: 10111110 00000000 11111111 XXXXXXXX
Second loop: 10111110 00000000 XXXXXXXX 00110011
Third loop: XXXXXXXX 00000000 11111111 00110011Each iteration of the loop returns the next 8-bit group that has at
least one set bit.The for_each_set_clump8 macro has four parameters:
* start: set to the bit offset of the current clump
* clump: set to the current clump value
* bits: bitmap to search within
* size: bitmap size in number of bitsIn this version of the patchset, the for_each_set_clump macro has been
reimplemented and simplified based on the suggestions provided by Rasmus
Villemoes and Andy Shevchenko in the version 4 submission.In particular, the function of the for_each_set_clump macro has been
restricted to handle only 8-bit clumps; the drivers that use the
for_each_set_clump macro only handle 8-bit ports so a generic
for_each_set_clump implementation is not necessary. Thus, a solution
for large clumps (i.e. those larger than the width of a bitmap word)
can be postponed until a driver appears that actually requires such a
generic for_each_set_clump implementation.For what it's worth, a semi-generic for_each_set_clump (i.e. for clumps
smaller than the width of a bitmap word) can be implemented by simply
replacing the hardcoded '8' and '0xFF' instances with respective
variables. I have not yet had a need for such an implementation, and
since it falls short of a true generic for_each_set_clump function, I
have decided to forgo such an implementation for now.In addition, the bitmap_get_value8 and bitmap_set_value8 functions are
introduced to get and set 8-bit values respectively. Their use is based
on the behavior suggested in the patchset version 4 review.This patch (of 14):
This macro iterates for each 8-bit group of bits (clump) with set bits,
within a bitmap memory region. For each iteration, "start" is set to
the bit offset of the found clump, while the respective clump value is
stored to the location pointed by "clump". Additionally, the
bitmap_get_value8 and bitmap_set_value8 functions are introduced to
respectively get and set an 8-bit value in a bitmap memory region.[gustavo@embeddedor.com: fix potential sign-extension overflow]
Link: http://lkml.kernel.org/r/20191015184657.GA26541@embeddedor
[akpm@linux-foundation.org: s/ULL/UL/, per Joe]
[vilhelm.gray@gmail.com: add for_each_set_clump8 documentation]
Link: http://lkml.kernel.org/r/20191016161825.301082-1-vilhelm.gray@gmail.com
Link: http://lkml.kernel.org/r/893c3b4f03266c9496137cc98ac2b1bd27f92c73.1570641097.git.vilhelm.gray@gmail.com
Signed-off-by: William Breathitt Gray
Signed-off-by: Gustavo A. R. Silva
Suggested-by: Andy Shevchenko
Suggested-by: Rasmus Villemoes
Suggested-by: Lukas Wunner
Tested-by: Andy Shevchenko
Cc: Arnd Bergmann
Cc: Linus Walleij
Cc: Bartosz Golaszewski
Cc: Masahiro Yamada
Cc: Geert Uytterhoeven
Cc: Phil Reid
Cc: Geert Uytterhoeven
Cc: Mathias Duckeck
Cc: Morten Hein Tiljeset
Cc: Sean Nyekjaer
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Initialization is not guaranteed to zero padding bytes so use an
explicit memset instead to avoid leaking any kernel content in any
possible padding bytes.Link: http://lkml.kernel.org/r/dfa331c00881d61c8ee51577a082d8bebd61805c.camel@perches.com
Signed-off-by: Joe Perches
Cc: Dan Carpenter
Cc: Julia Lawall
Cc: Thomas Gleixner
Cc: Kees Cook
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
When building with clang + -Wtautological-pointer-compare, these
instances pop up:kernel/profile.c:339:6: warning: comparison of array 'prof_cpu_mask' not equal to a null pointer is always true [-Wtautological-pointer-compare]
if (prof_cpu_mask != NULL)
^~~~~~~~~~~~~ ~~~~
kernel/profile.c:376:6: warning: comparison of array 'prof_cpu_mask' not equal to a null pointer is always true [-Wtautological-pointer-compare]
if (prof_cpu_mask != NULL)
^~~~~~~~~~~~~ ~~~~
kernel/profile.c:406:26: warning: comparison of array 'prof_cpu_mask' not equal to a null pointer is always true [-Wtautological-pointer-compare]
if (!user_mode(regs) && prof_cpu_mask != NULL &&
^~~~~~~~~~~~~ ~~~~
3 warnings generated.This can be addressed with the cpumask_available helper, introduced in
commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") to fix
warnings like this while keeping the code the same.Link: https://github.com/ClangBuiltLinux/linux/issues/747
Link: http://lkml.kernel.org/r/20191022191957.9554-1-natechancellor@gmail.com
Signed-off-by: Nathan Chancellor
Reviewed-by: Andrew Morton
Cc: Thomas Gleixner
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds