firewire-ohci: work around oversized DMA reads on JMicron controllers
Subsystems (5)
PATCH 150/189 MIPS: Generic: Support GIC in EIC mode
In reply to Sasha LevinFrom: Matt Redfearn <[email protected]>
[ Upstream commit 7bf8b16d1b60419c865e423b907a05f413745b3e ]
The GIC supports running in External Interrupt Controller (EIC) mode, and will signal this via cpu_has_veic if enabled in hardware. Currently the generic kernel will panic if cpu_has_veic is set - but the GIC can legitimately set this flag if either configured to boot in EIC mode, or if the GIC driver enables this mode. Make the kernel not panic in this case, and instead just check if the GIC is present. If so, use it's CPU local interrupt routing functions. If an EIC is present, but it is not the GIC, then the kernel does not know how to get the VIRQ for the CPU local interrupts and should panic. Support for alternative EICs being present is needed here for the generic kernel to support them.
Patchwork: https://patchwork.linux-mips.org/patch/18191/
--- arch/mips/generic/irq.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/mips/generic/irq.c +9 -9
@@ -22,10 +22,10 @@ int get_c0_fdc_int(void) {int mips_cpu_fdc_irq; -if (cpu_has_veic) -panic ("Unimplemented!" ); -else if (mips_gic_present ()) +if (mips_gic_present ()) mips_cpu_fdc_irq =gic_get_c0_fdc_int (); +else if (cpu_has_veic) +panic ("Unimplemented!" );else if (cp0_fdc_irq >=0 ) mips_cpu_fdc_irq =MIPS_CPU_IRQ_BASE + cp0_fdc_irq;else
@@ -38,10 +38,10 @@ int get_c0_perfcount_int(void) {int mips_cpu_perf_irq; -if (cpu_has_veic) -panic ("Unimplemented!" ); -else if (mips_gic_present ()) +if (mips_gic_present ()) mips_cpu_perf_irq =gic_get_c0_perfcount_int (); +else if (cpu_has_veic) +panic ("Unimplemented!" );else if (cp0_perfcount_irq >=0 ) mips_cpu_perf_irq =MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;else
@@ -54,10 +54,10 @@ unsigned int get_c0_compare_int(void) {int mips_cpu_timer_irq; -if (cpu_has_veic) -panic ("Unimplemented!" ); -else if (mips_gic_present ()) +if (mips_gic_present ()) mips_cpu_timer_irq =gic_get_c0_compare_int (); +else if (cpu_has_veic) +panic ("Unimplemented!" );else mips_cpu_timer_irq =MIPS_CPU_IRQ_BASE + cp0_compare_irq;
Signature · 1 line
2.15.1
PATCH 151/189 perf evsel: Fix period/freq terms setup
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit 49c0ae80eb32426fa133246200628e529067c595 ]
Stephane reported that we don't set properly PERIOD sample type for events with period term defined.
Before:
$ perf record -e cpu/cpu-cycles,period=1000/u ls $ perf evlist -v cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME|PERIOD, ...
After:
$ perf record -e cpu/cpu-cycles,period=1000/u ls $ perf evlist -v cpu/cpu-cycles,period=1000/u: ... sample_type: IP|TID|TIME, ...
Setting PERIOD sample type based on period term setup.
Committer note:
When we use -c or a period=N term in the event definition, then we don't need to ask the kernel, for this event, via perf_event_attr.sample_type |= PERF_SAMPLE_PERIOD, to put the event period in each sample for this event, as we know it already, it is in perf_event_attr.sample_period.
--- tools/perf/util/evsel.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/evsel.c +2 -0
@@ -736,12 +736,14 @@ static void apply_config_terms(struct perf_evsel *evsel,if (!(term->weak && opts->user_interval !=ULLONG_MAX )) { attr->sample_period = term->val.period; attr->freq =0 ; +perf_evsel__reset_sample_bit (evsel,PERIOD ); }break ;case PERF_EVSEL__CONFIG_TERM_FREQ :if (!(term->weak && opts->user_freq !=UINT_MAX )) { attr->sample_freq = term->val.freq; attr->freq =1 ; +perf_evsel__set_sample_bit (evsel,PERIOD ); }break ;case PERF_EVSEL__CONFIG_TERM_TIME :
Signature · 1 line
2.15.1
PATCH 152/189 xen-netfront: Fix race between device setup and open
In reply to Sasha LevinFrom: Ross Lagerwall <[email protected]>
[ Upstream commit f599c64fdf7d9c108e8717fb04bc41c680120da4 ]
When a netfront device is set up it registers a netdev fairly early on, before it has set up the queues and is actually usable. A userspace tool like NetworkManager will immediately try to open it and access its state as soon as it appears. The bug can be reproduced by hotplugging VIFs until the VM runs out of grant refs. It registers the netdev but fails to set up any queues (since there are no more grant refs). In the meantime, NetworkManager opens the device and the kernel crashes trying to access the queues (of which there are none).
Fix this in two ways:
* For initial setup, register the netdev much later, after the queues are setup. This avoids the race entirely.
* During a suspend/resume cycle, the frontend reconnects to the backend and the queues are recreated. It is possible (though highly unlikely) to race with something opening the device and accessing the queues after they have been destroyed but before they have been recreated. Extend the region covered by the rtnl semaphore to protect against this race. There is a possibility that we fail to recreate the queues so check for this in the open function.
--- drivers/net/xen-netfront.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/net/xen-netfront.c +24 -22
@@ -351,6 +351,9 @@ static int xennet_open(struct net_device *dev)unsigned int i =0 ;struct netfront_queue *queue =NULL ; +if (!np->queues) +return -ENODEV ; +for (i =0 ; i < num_queues; ++i) { queue = &np->queues[i];napi_enable (&queue->napi);
@@ -1358,18 +1361,8 @@ static int netfront_probe(struct xenbus_device *dev,#ifdef CONFIG_SYSFS info->netdev->sysfs_groups[0 ] = &xennet_dev_group;#endif - err =register_netdev (info->netdev); -if (err) { -pr_warn ("%s: register_netdev err=%d\n" , __func__, err); - goto fail; - }return 0 ; - - fail: -xennet_free_netdev (netdev); -dev_set_drvdata (&dev->dev,NULL ); -return err; }static void xennet_end_access (int ref,void *page)
@@ -1737,8 +1730,6 @@ static void xennet_destroy_queues(struct netfront_info *info) {unsigned int i; -rtnl_lock (); -for (i =0 ; i < info->netdev->real_num_tx_queues; i++) {struct netfront_queue *queue = &info->queues[i];
@@ -1747,8 +1738,6 @@ static void xennet_destroy_queues(struct netfront_info *info)netif_napi_del (&queue->napi); } -rtnl_unlock (); -kfree (info->queues); info->queues =NULL ; }
@@ -1764,8 +1753,6 @@ static int xennet_create_queues(struct netfront_info *info,if (!info->queues)return -ENOMEM ; -rtnl_lock (); -for (i =0 ; i < *num_queues; i++) {struct netfront_queue *queue = &info->queues[i];
@@ -1774,7 +1761,7 @@ static int xennet_create_queues(struct netfront_info *info, ret =xennet_init_queue (queue);if (ret <0 ) { -dev_warn (&info->netdev->dev, +dev_warn (&info->xbdev->dev,"only created %d queues\n" , i); *num_queues = i;break ;
@@ -1788,10 +1775,8 @@ static int xennet_create_queues(struct netfront_info *info,netif_set_real_num_tx_queues (info->netdev, *num_queues); -rtnl_unlock (); -if (*num_queues ==0 ) { -dev_err (&info->netdev->dev,"no queues\n" ); +dev_err (&info->xbdev->dev,"no queues\n" );return -EINVAL ; }return 0 ;
@@ -1828,6 +1813,7 @@ static int talk_to_netback(struct xenbus_device *dev, goto out; } +rtnl_lock ();if (info->queues)xennet_destroy_queues (info);
@@ -1838,6 +1824,7 @@ static int talk_to_netback(struct xenbus_device *dev, info->queues =NULL ; goto out; } +rtnl_unlock ();/* Create shared ring, alloc event channel -- for each queue */ for (i =0 ; i < num_queues; ++i) {
@@ -1934,8 +1921,10 @@ abort_transaction_no_dev_fatal:xenbus_transaction_end (xbt,1 ); destroy_ring:xennet_disconnect_backend (info); +rtnl_lock ();xennet_destroy_queues (info); out: +rtnl_unlock ();device_unregister (&dev->dev);return err; }
@@ -1965,6 +1954,15 @@ static int xennet_connect(struct net_device *dev)netdev_update_features (dev);rtnl_unlock (); +if (dev->reg_state ==NETREG_UNINITIALIZED ) { + err =register_netdev (dev); +if (err) { +pr_warn ("%s: register_netdev err=%d\n" , __func__, err); +device_unregister (&np->xbdev->dev); +return err; + } + } +/* * All public and private state should now be sane. Get * ready to start sending and receiving packets and give the driver
@@ -2150,10 +2148,14 @@ static int xennet_remove(struct xenbus_device *dev)xennet_disconnect_backend (info); -unregister_netdev (info->netdev); +if (info->netdev->reg_state ==NETREG_REGISTERED ) +unregister_netdev (info->netdev); -if (info->queues) +if (info->queues) { +rtnl_lock ();xennet_destroy_queues (info); +rtnl_unlock (); + }xennet_free_netdev (info->netdev);return 0 ;
Signature · 1 line
2.15.1
PATCH 153/189 xen/grant-table: Use put_page instead of free_page
In reply to Sasha LevinFrom: Ross Lagerwall <[email protected]>
[ Upstream commit 3ac7292a25db1c607a50752055a18aba32ac2176 ]
The page given to gnttab_end_foreign_access() to free could be a compound page so use put_page() instead of free_page() since it can handle both compound and single pages correctly.
This bug was discovered when migrating a Xen VM with several VIFs and CONFIG_DEBUG_VM enabled. It hits a BUG usually after fewer than 10 iterations. All netfront devices disconnect from the backend during a suspend/resume and this will call gnttab_end_foreign_access() if a netfront queue has an outstanding skb. The mismatch between calling get_page() and free_page() on a compound page causes a reference counting error which is detected when DEBUG_VM is enabled.
--- drivers/xen/grant-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/grant-table.c +2 -2
@@ -382,7 +382,7 @@ static void gnttab_handle_deferred(struct timer_list *unused)if (entry->page) {pr_debug ("freeing g.e. %#x (pfn %#lx)\n" , entry->ref,page_to_pfn (entry->page)); -__free_page (entry->page); +put_page (entry->page); }else pr_info ("freeing g.e. %#x\n" , entry->ref);kfree (entry);
@@ -438,7 +438,7 @@ void gnttab_end_foreign_access(grant_ref_t ref, int readonly,if (gnttab_end_foreign_access_ref (ref, readonly)) {put_free_entry (ref);if (page !=0 ) -free_page (page); +put_page (virt_to_page (page)); }else gnttab_add_deferred (ref, readonly, page ?virt_to_page (page) :NULL );
Signature · 1 line
2.15.1
PATCH 154/189 bpf: sockmap, fix leaking maps with attached but not detached progs
In reply to Sasha LevinFrom: John Fastabend <[email protected]>
[ Upstream commit 3d9e952697de89b53227f06d4241f275eb99cfc4 ]
When a program is attached to a map we increment the program refcnt to ensure that the program is not removed while it is potentially being referenced from sockmap side. However, if this same program also references the map (this is a reasonably common pattern in my programs) then the verifier will also increment the maps refcnt from the verifier. This is to ensure the map doesn't get garbage collected while the program has a reference to it.
So we are left in a state where the map holds the refcnt on the program stopping it from being removed and releasing the map refcnt. And vice versa the program holds a refcnt on the map stopping it from releasing the refcnt on the prog.
All this is fine as long as users detach the program while the map fd is still around. But, if the user omits this detach command we are left with a dangling map we can no longer release.
To resolve this when the map fd is released decrement the program references and remove any reference from the map to the program. This fixes the issue with possibly dangling map and creates a user side API constraint. That is, the map fd must be held open for programs to be attached to a map.
--- kernel/bpf/sockmap.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
kernel/bpf/sockmap.c +14 -5
@@ -604,11 +604,6 @@ static void sock_map_free(struct bpf_map *map) }rcu_read_unlock (); -if (stab->bpf_verdict) -bpf_prog_put (stab->bpf_verdict); -if (stab->bpf_parse) -bpf_prog_put (stab->bpf_parse); -sock_map_remove_complete (stab); }
@@ -880,6 +875,19 @@ static int sock_map_update_elem(struct bpf_map *map,return err; } +static void sock_map_release (struct bpf_map *map,struct file *map_file) +{ + struct bpf_stab *stab = container_of(map, struct bpf_stab, map); +struct bpf_prog *orig; + + orig =xchg (&stab->bpf_parse,NULL ); +if (orig) +bpf_prog_put (orig); + orig =xchg (&stab->bpf_verdict,NULL ); +if (orig) +bpf_prog_put (orig); +} +const struct bpf_map_ops sock_map_ops = { .map_alloc = sock_map_alloc, .map_free = sock_map_free,
@@ -887,6 +895,7 @@ const struct bpf_map_ops sock_map_ops = { .map_get_next_key = sock_map_get_next_key, .map_update_elem = sock_map_update_elem, .map_delete_elem = sock_map_delete_elem, + .map_release = sock_map_release, }; BPF_CALL_4(bpf_sock_map_update, struct bpf_sock_ops_kern *, bpf_sock,
Signature · 1 line
2.15.1
PATCH 155/189 RDS: IB: Fix null pointer issue
In reply to Sasha LevinFrom: Guanglei Li <[email protected]>
[ Upstream commit 2c0aa08631b86a4678dbc93b9caa5248014b4458 ]
Scenario:
1. Port down and do fail over
2. Ap do rds_bind syscall
PID: 47039 TASK: ffff89887e2fe640 CPU: 47 COMMAND: "kworker/u:6"
#0 [ffff898e35f159f0] machine_kexec at ffffffff8103abf9 #1 [ffff898e35f15a60] crash_kexec at ffffffff810b96e3 #2 [ffff898e35f15b30] oops_end at ffffffff8150f518
#3 [ffff898e35f15b60] no_context at ffffffff8104854c
#4 [ffff898e35f15ba0] __bad_area_nosemaphore at ffffffff81048675 #5 [ffff898e35f15bf0] bad_area_nosemaphore at ffffffff810487d3 #6 [ffff898e35f15c00] do_page_fault at ffffffff815120b8 #7 [ffff898e35f15d10] page_fault at ffffffff8150ea95
[exception RIP: unknown or invalid address]
RIP: 0000000000000000 RSP: ffff898e35f15dc8 RFLAGS: 00010282
RAX: 00000000fffffffe RBX: ffff889b77f6fc00 RCX:ffffffff81c99d88
RDX: 0000000000000000 RSI: ffff896019ee08e8 RDI:ffff889b77f6fc00
RBP: ffff898e35f15df0 R8: ffff896019ee08c8 R9:0000000000000000
R10: 0000000000000400 R11: 0000000000000000 R12:ffff896019ee08c0
R13: ffff889b77f6fe68 R14: ffffffff81c99d80 R15: ffffffffa022a1e0
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #8 [ffff898e35f15dc8] cma_ndev_work_handler at ffffffffa022a228 [rdma_cm] #9 [ffff898e35f15df8] process_one_work at ffffffff8108a7c6 #10 [ffff898e35f15e58] worker_thread at ffffffff8108bda0
#11 [ffff898e35f15ee8] kthread at ffffffff81090fe6
PID: 45659 TASK: ffff880d313d2500 CPU: 31 COMMAND: "oracle_45659_ap"
#0 [ffff881024ccfc98] __schedule at ffffffff8150bac4
#1 [ffff881024ccfd40] schedule at ffffffff8150c2cf
#2 [ffff881024ccfd50] __mutex_lock_slowpath at ffffffff8150cee7 #3 [ffff881024ccfdc0] mutex_lock at ffffffff8150cdeb
#4 [ffff881024ccfde0] rdma_destroy_id at ffffffffa022a027 [rdma_cm] #5 [ffff881024ccfe10] rds_ib_laddr_check at ffffffffa0357857 [rds_rdma] #6 [ffff881024ccfe50] rds_trans_get_preferred at ffffffffa0324c2a [rds] #7 [ffff881024ccfe80] rds_bind at ffffffffa031d690 [rds]
#8 [ffff881024ccfeb0] sys_bind at ffffffff8142a670
PID: 45659 PID: 47039rds_ib_laddr_check
/* create id_priv with a null event_handler */ rdma_create_id
rdma_bind_addr
cma_acquire_dev
/* add id_priv to cma_dev->id_list */
cma_attach_to_dev
cma_ndev_work_handler
/* event_hanlder is null */
id_priv->id.event_handler--- net/rds/ib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/ib.c +2 -1
@@ -347,7 +347,8 @@ static int rds_ib_laddr_check(struct net *net, __be32 addr)/* Create a CMA ID and try to bind it. This catches both * IB and iWARP capable NICs. */ - cm_id =rdma_create_id (&init_net,NULL ,NULL ,RDMA_PS_TCP ,IB_QPT_RC ); + cm_id =rdma_create_id (&init_net, rds_rdma_cm_event_handler, +NULL ,RDMA_PS_TCP ,IB_QPT_RC );if (IS_ERR (cm_id))return PTR_ERR (cm_id);
Signature · 1 line
2.15.1
PATCH 156/189 arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit 202fb4ef81e3ec765c23bd1e6746a5c25b797d0e ]
If the spinlock "next" ticket wraps around between the initial LDR and the cmpxchg in the LSE version of spin_trylock, then we can erroneously think that we have successfuly acquired the lock because we only check whether the next ticket return by the cmpxchg is equal to the owner ticket in our updated lock word.
This patch fixes the issue by performing a full 32-bit check of the lock word when trying to determine whether or not the CASA instruction updated memory.
--- arch/arm64/include/asm/spinlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/spinlock.h +2 -2
@@ -87,8 +87,8 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)" cbnz %w1, 1f\n" " add %w1, %w0, %3\n" " casa %w0, %w1, %2\n" -" and %w1, %w1, #0xffff\n" -" eor %w1, %w1, %w0, lsr #16\n" +" sub %w1, %w1, %3\n" +" eor %w1, %w1, %w0\n" "1:") : "=&r" (lockval), "=&r" (tmp), "+Q" (*lock) : "I" (1 << TICKET_SHIFT)
Signature · 1 line
2.15.1
PATCH 157/189 proc: fix /proc/*/map_files lookup
In reply to Sasha LevinFrom: Alexey Dobriyan <[email protected]>
[ Upstream commit ac7f1061c2c11bb8936b1b6a94cdb48de732f7a4 ]
Current code does:
if (sscanf(dentry->d_name.name, "%lx-%lx", start, end) != 2)
However sscanf() is broken garbage.
It silently accepts whitespace between format specifiers (did you know that?).
It silently accepts valid strings which result in integer overflow.
Do not use sscanf() for any even remotely reliable parsing code.
OK # readlink '/proc/1/map_files/55a23af39000-55a23b05b000' /lib/systemd/systemd broken # readlink '/proc/1/map_files/ 55a23af39000-55a23b05b000' /lib/systemd/systemd broken # readlink '/proc/1/map_files/55a23af39000-55a23b05b000 ' /lib/systemd/systemd very broken # readlink '/proc/1/map_files/1000000000000000055a23af39000-55a23b05b000' /lib/systemd/systemd
Andrei said:
: This patch breaks criu. It was a bug in criu. And this bug is on a minor : path, which works when memfd_create() isn't available. It is a reason why : I ask to not backport this patch to stable kernels.
:
: In CRIU this bug can be triggered, only if this patch will be backported : to a kernel which version is lower than v3.16.
--- fs/proc/base.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
fs/proc/base.c +28 -1
@@ -100,6 +100,8 @@#include "internal.h" #include "fd.h" +#include "../../lib/kstrtox.h" +/* NOTE: * Implementing inode permission operations in /proc is almost * certainly an error. Permission checks need to happen during
@@ -1907,8 +1909,33 @@ end_instantiate:static int dname_to_vma_addr (struct dentry *dentry,unsigned long *start,unsigned long *end) { -if (sscanf (dentry->d_name.name,"%lx-%lx" , start, end) !=2 ) +const char *str = dentry->d_name.name; +unsigned long long sval, eval; +unsigned int len; + + len =_parse_integer (str,16 , &sval); +if (len &KSTRTOX_OVERFLOW ) +return -EINVAL ; +if (sval != (unsigned long )sval) +return -EINVAL ; + str += len; + +if (*str !='-' )return -EINVAL ; + str++; + + len =_parse_integer (str,16 , &eval); +if (len &KSTRTOX_OVERFLOW ) +return -EINVAL ; +if (eval != (unsigned long )eval) +return -EINVAL ; + str += len; + +if (*str !='\0' ) +return -EINVAL ; + + *start = sval; + *end = eval;return 0 ; }
Signature · 1 line
2.15.1
PATCH 158/189 PM / domains: Fix up domain-idle-states OF parsing
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit a3381e3a65cbaf612c8f584906c4dba27e84267c ]
Commit b539cc82d493 (PM / Domains: Ignore domain-idle-states that are not compatible), made it possible to ignore non-compatible domain-idle-states OF nodes. However, in case that happens while doing the OF parsing, the number of elements in the allocated array would exceed the numbers actually needed, thus wasting memory.
Fix this by pre-iterating the genpd OF node and counting the number of compatible domain-idle-states nodes, before doing the allocation. While doing this, it makes sense to rework the code a bit to avoid open coding, of parts responsible for the OF node iteration.
Let's also take the opportunity to clarify the function header for of_genpd_parse_idle_states(), about what is being returned in case of errors.
--- drivers/base/power/domain.c | 76 +++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 31 deletions(-)
drivers/base/power/domain.c +45 -31
@@ -2293,6 +2293,38 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,return 0 ; } +static int genpd_iterate_idle_states (struct device_node *dn, +struct genpd_power_state *states) +{ +int ret; +struct of_phandle_iterator it; +struct device_node *np; +int i =0 ; + + ret =of_count_phandle_with_args (dn,"domain-idle-states" ,NULL ); +if (ret <=0 ) +return ret; + +/* Loop over the phandles until all the requested entry is found */ +of_for_each_phandle (&it, ret, dn,"domain-idle-states" ,NULL ,0 ) { + np = it.node; +if (!of_match_node (idle_state_match, np)) +continue ; +if (states) { + ret =genpd_parse_state (&states[i], np); +if (ret) { +pr_err ("Parsing idle state node %pOF failed with err %d\n" , + np, ret); +of_node_put (np); +return ret; + } + } + i++; + } + +return i; +} +/** * of_genpd_parse_idle_states: Return array of idle states for the genpd. *
@@ -2302,49 +2334,31 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,* * Returns the device states parsed from the OF node. The memory for the states * is allocated by this function and is the responsibility of the caller to -* free the memory after use. +* free the memory after use. If no domain idle states is found it returns +* -EINVAL and in case of errors, a negative error code. */ int of_genpd_parse_idle_states (struct device_node *dn,struct genpd_power_state **states,int *n) {struct genpd_power_state *st; -struct device_node *np; -int i =0 ; -int err, ret; -int count; -struct of_phandle_iterator it; -const struct of_device_id *match_id; +int ret; - count =of_count_phandle_with_args (dn,"domain-idle-states" ,NULL ); -if (count <=0 ) -return -EINVAL ; + ret =genpd_iterate_idle_states (dn,NULL ); +if (ret <=0 ) +return ret <0 ? ret : -EINVAL ; - st =kcalloc (count,sizeof (*st),GFP_KERNEL ); + st =kcalloc (ret,sizeof (*st),GFP_KERNEL );if (!st)return -ENOMEM ; -/* Loop over the phandles until all the requested entry is found */ -of_for_each_phandle (&it, err, dn,"domain-idle-states" ,NULL ,0 ) { - np = it.node; - match_id =of_match_node (idle_state_match, np); -if (!match_id) -continue ; - ret =genpd_parse_state (&st[i++], np); -if (ret) { -pr_err - ("Parsing idle state node %pOF failed with err %d\n" , - np, ret); -of_node_put (np); -kfree (st); -return ret; - } + ret =genpd_iterate_idle_states (dn, st); +if (ret <=0 ) { +kfree (st); +return ret <0 ? ret : -EINVAL ; } - *n = i; -if (!i) -kfree (st); -else - *states = st; + *states = st; + *n = ret;return 0 ; }
Signature · 1 line
2.15.1
PATCH 159/189 cifs: silence compiler warnings showing up with gcc-8.0.0
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit ade7db991b47ab3016a414468164f4966bd08202 ]
This bug was fixed before, but came up again with the latest compiler in another function:
fs/cifs/cifssmb.c: In function 'CIFSSMBSetEA':fs/cifs/cifssmb.c:6362:3: error: 'strncpy' offset 8 is out of the bounds [0, 4] [-Werror=array-bounds]
strncpy(parm_data->list[0].name, ea_name, name_len);
Let's apply the same fix that was used for the other instances.
--- fs/cifs/cifssmb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/cifs/cifssmb.c +1 -3
@@ -6331,9 +6331,7 @@ SetEARetry: pSMB->InformationLevel =cpu_to_le16 (SMB_SET_FILE_EA ); - parm_data = - (struct fealist *) (((char *) &pSMB->hdr.Protocol) + - offset); + parm_data = (void *)pSMB + offsetof(struct smb_hdr , Protocol) + offset; pSMB->ParameterOffset =cpu_to_le16 (param_offset); pSMB->DataOffset =cpu_to_le16 (offset); pSMB->SetupCount =1 ;
Signature · 1 line
2.15.1
PATCH 160/189 bcache: properly set task state in bch_writeback_thread()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 99361bbf26337186f02561109c17a4c4b1a7536a ]
Kernel thread routine bch_writeback_thread() has the following code block,
447 down_write(&dc->writeback_lock);
448~450 if (check conditions) {
451 up_write(&dc->writeback_lock);
452 set_current_state(TASK_INTERRUPTIBLE);
453
454 if (kthread_should_stop())
455 return 0;
456
457 schedule();
458 continue;
459 }
If condition check is true, its task state is set to TASK_INTERRUPTIBLE and call schedule() to wait for others to wake up it.
There are 2 issues in current code,
1, Task state is set to TASK_INTERRUPTIBLE after the condition checks, if
another process changes the condition and call wake_up_process(dc-> writeback_thread), then at line 452 task state is set back to TASK_INTERRUPTIBLE, the writeback kernel thread will lose a chance to be waken up.
2, At line 454 if kthread_should_stop() is true, writeback kernel thread
will return to kernel/kthread.c:kthread() with TASK_INTERRUPTIBLE and call do_exit(). It is not good to enter do_exit() with task state TASK_INTERRUPTIBLE, in following code path might_sleep() is called and a warning message is reported by __might_sleep(): "WARNING: do not call blocking ops when !TASK_RUNNING; state=1 set at [xxxx]".
For the first issue, task state should be set before condition checks. Ineed because dc->writeback_lock is required when modifying all the conditions, calling set_current_state() inside code block where dc-> writeback_lock is hold is safe. But this is quite implicit, so I still move set_current_state() before all the condition checks.
For the second issue, frankley speaking it does not hurt when kernel thread exits with TASK_INTERRUPTIBLE state, but this warning message scares users, makes them feel there might be something risky with bcache and hurt their data. Setting task state to TASK_RUNNING before returning fixes this problem.
In alloc.c:allocator_wait(), there is also a similar issue, and is also fixed in this patch.
Changelog:
v3: merge two similar fixes into one patch
v2: fix the race issue in v1 patch.
v1: initial buggy fix.
--- drivers/md/bcache/alloc.c | 4 +++- drivers/md/bcache/writeback.c | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/md/bcache/alloc.c +3 -1
@@ -287,8 +287,10 @@ do { \break ; \ \mutex_unlock (&(ca)->set->bucket_lock); \ -if (kthread_should_stop ()) \ +if (kthread_should_stop ()) { \ +set_current_state (TASK_RUNNING ); \return 0 ; \ + } \ \schedule (); \mutex_lock (&(ca)->set->bucket_lock); \
drivers/md/bcache/writeback.c +5 -2
@@ -445,18 +445,21 @@ static int bch_writeback_thread(void *arg)while (!kthread_should_stop ()) {down_write (&dc->writeback_lock); +set_current_state (TASK_INTERRUPTIBLE );if (!atomic_read (&dc->has_dirty) || (!test_bit (BCACHE_DEV_DETACHING , &dc->disk.flags) && !dc->writeback_running)) {up_write (&dc->writeback_lock); -set_current_state (TASK_INTERRUPTIBLE ); -if (kthread_should_stop ()) +if (kthread_should_stop ()) { +set_current_state (TASK_RUNNING );return 0 ; + }schedule ();continue ; } +set_current_state (TASK_RUNNING ); searched_full_index =refill_dirty (dc);
Signature · 1 line
2.15.1
PATCH 161/189 bcache: fix for allocator and register thread race
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 682811b3ce1a5a4e20d700939a9042f01dbc66c4 ]
After long time running of random small IO writing, I reboot the machine, and after the machine power on, I found bcache got stuck, the stack is:
[root@ceph153 ~]# cat /proc/2510/task/*/stack
[<ffffffffa06b2455>] closure_sync+0x25/0x90 [bcache] [<ffffffffa06b6be8>] bch_journal+0x118/0x2b0 [bcache] [<ffffffffa06b6dc7>] bch_journal_meta+0x47/0x70 [bcache] [<ffffffffa06be8f7>] bch_prio_write+0x237/0x340 [bcache] [<ffffffffa06a8018>] bch_allocator_thread+0x3c8/0x3d0 [bcache] [<ffffffff810a631f>] kthread+0xcf/0xe0 [<ffffffff8164c318>] ret_from_fork+0x58/0x90 [<ffffffffffffffff>] 0xffffffffffffffff [root@ceph153 ~]# cat /proc/2038/task/*/stack [<ffffffffa06b1abd>] __bch_btree_map_nodes+0x12d/0x150 [bcache] [<ffffffffa06b1bd1>] bch_btree_insert+0xf1/0x170 [bcache] [<ffffffffa06b637f>] bch_journal_replay+0x13f/0x230 [bcache] [<ffffffffa06c75fe>] run_cache_set+0x79a/0x7c2 [bcache] [<ffffffffa06c0cf8>] register_bcache+0xd48/0x1310 [bcache] [<ffffffff812f702f>] kobj_attr_store+0xf/0x20 [<ffffffff8125b216>] sysfs_write_file+0xc6/0x140 [<ffffffff811dfbfd>] vfs_write+0xbd/0x1e0 [<ffffffff811e069f>] SyS_write+0x7f/0xe0 [<ffffffff8164c3c9>] system_call_fastpath+0x16/0x1
The stack shows the register thread and allocator thread were getting stuck when registering cache device.
I reboot the machine several times, the issue always exsit in this machine.
I debug the code, and found the call trace as bellow:register_bcache()
==>run_cache_set()
==>bch_journal_replay()
==>bch_btree_insert()
==>__bch_btree_map_nodes()
==>btree_insert_fn()
==>btree_split() //node need split
==>btree_check_reserve()In btree_check_reserve(), It will check if there is enough buckets of RESERVE_BTREE type, since allocator thread did not work yet, so no buckets of RESERVE_BTREE type allocated, so the register thread waits on c->btree_cache_wait, and goes to sleep.
Then the allocator thread initialized, the call trace is bellow:bch_allocator_thread()
==>bch_prio_write()
==>bch_journal_meta()
==>bch_journal()
==>journal_wait_for_write()In journal_wait_for_write(), It will check if journal is full by journal_full(), but the long time random small IO writing causes the exhaustion of journal buckets(journal.blocks_free=0), In order to release the journal buckets,
the allocator calls btree_flush_write() to flush keys to btree nodes, and waits on c->journal.wait until btree nodes writing over or there has already some journal buckets space, then the allocator thread goes to sleep. but in btree_flush_write(), since bch_journal_replay() is not finished, so no btree nodes have journal (condition "if (btree_current_write(b)->journal)" never satisfied), so we got no btree node to flush, no journal bucket released, and allocator sleep all the times.
Through the above analysis, we can see that:
1) Register thread wait for allocator thread to allocate buckets of RESERVE_BTREE type;
2) Alloctor thread wait for register thread to replay journal, so it can flush btree nodes and get journal bucket.
then they are all got stuck by waiting for each other.
Hua Rui provided a patch for me, by allocating some buckets of RESERVE_BTREE type in advance, so the register thread can get bucket when btree node splitting and no need to waiting for the allocator thread. I tested it, it has effect, and register thread run a step forward, but finally are still got stuck, the reason is only 8 bucket of RESERVE_BTREE type were allocated, and in bch_journal_replay(), after 2 btree nodes splitting, only 4 bucket of RESERVE_BTREE type left, then btree_check_reserve() is not satisfied anymore, so it goes to sleep again, and in the same time, alloctor thread did not flush enough btree nodes to release a journal bucket, so they all got stuck again.
So we need to allocate more buckets of RESERVE_BTREE type in advance, but how much is enough? By experience and test, I think it should be as much as journal buckets. Then I modify the code as this patch, and test in the machine, and it works.
This patch modified base on Hua Rui’s patch, and allocate more buckets of RESERVE_BTREE type in advance to avoid register thread and allocate thread going to wait for each other.
[patch v2] ca->sb.njournal_buckets would be 0 in the first time after cache creation, and no journal exists, so just 8 btree buckets is OK.
--- drivers/md/bcache/btree.c | 9 ++++++--- drivers/md/bcache/super.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/md/bcache/btree.c +6 -3
@@ -1871,14 +1871,17 @@ void bch_initial_gc_finish(struct cache_set *c)*/ for_each_cache (ca, c, i) {for_each_bucket (b, ca) { -if (fifo_full (&ca->free[RESERVE_PRIO ])) +if (fifo_full (&ca->free[RESERVE_PRIO ]) && +fifo_full (&ca->free[RESERVE_BTREE ]))break ;if (bch_can_invalidate_bucket (ca, b) && !GC_MARK (b)) {__bch_invalidate_one_bucket (ca, b); -fifo_push (&ca->free[RESERVE_PRIO ], - b - ca->buckets); +if (!fifo_push (&ca->free[RESERVE_PRIO ], + b - ca->buckets)) +fifo_push (&ca->free[RESERVE_BTREE ], + b - ca->buckets); } } }
drivers/md/bcache/super.c +12 -1
@@ -1833,6 +1833,7 @@ void bch_cache_release(struct kobject *kobj)static int cache_alloc (struct cache *ca) {size_t free; +size_t btree_buckets;struct bucket *b;__module_get (THIS_MODULE );
@@ -1840,9 +1841,19 @@ static int cache_alloc(struct cache *ca)bio_init (&ca->journal.bio, ca->journal.bio.bi_inline_vecs,8 ); +/* +* when ca->sb.njournal_buckets is not zero, journal exists, +* and in bch_journal_replay(), tree node may split, +* so bucket of RESERVE_BTREE type is needed, +* the worst situation is all journal buckets are valid journal, +* and all the keys need to replay, +* so the number of RESERVE_BTREE type buckets should be as much +* as journal buckets +*/ + btree_buckets = ca->sb.njournal_buckets ?:8 ; free =roundup_pow_of_two (ca->sb.nbuckets) >>10 ; - if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || + if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets, GFP_KERNEL) || !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
Signature · 1 line
2.15.1
PATCH 162/189 bcache: fix for data collapse after re-attaching an attached device
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 73ac105be390c1de42a2f21643c9778a5e002930 ]
back-end device sdm has already attached a cache_set with ID f67ebe1f-f8bc-4d73-bfe5-9dc88607f119, then try to attach with another cache set, and it returns with an error:
[root]# cd /sys/block/sdm/bcache
[root]# echo 5ccd0a63-148e-48b8-afa2-aca9cbd6279f > attach -bash: echo: write error: Invalid argument
After that, execute a command to modify the label of bcache device:
[root]# echo data_disk1 > label
Then we reboot the system, when the system power on, the back-end device can not attach to cache_set, a messages show in the log:
Feb 5 12:05:52 ceph152 kernel: [922385.508498] bcache:
bch_cached_dev_attach() couldn't find uuid for sdm in set
In sysfs_attach(), dc->sb.set_uuid was assigned to the value which input through sysfs, no matter whether it is success or not in bch_cached_dev_attach(). For example, If the back-end device has already attached to an cache set, bch_cached_dev_attach() would fail, but dc->sb.set_uuid was changed. Then modify the label of bcache device, it will call bch_write_bdev_super(), which would write the dc->sb.set_uuid to the super block, so we record a wrong cache set ID in the super block, after the system reboot, the cache set couldn't find the uuid of the back-end device, so the bcache device couldn't exist and use any more.
In this patch, we don't assigned cache set ID to dc->sb.set_uuid in sysfs_attach() directly, but input it into bch_cached_dev_attach(), and assigned dc->sb.set_uuid to the cache set ID after the back-end device attached to the cache set successful.
--- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 10 ++++++---- drivers/md/bcache/sysfs.c | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-)
drivers/md/bcache/bcache.h +1 -1
@@ -907,7 +907,7 @@ void bcache_write_super(struct cache_set *);int bch_flash_dev_create (struct cache_set *c,uint64_t size); -int bch_cached_dev_attach (struct cached_dev *,struct cache_set *); +int bch_cached_dev_attach (struct cached_dev *,struct cache_set *,uint8_t *);void bch_cached_dev_detach (struct cached_dev *);void bch_cached_dev_run (struct cached_dev *);void bcache_device_stop (struct bcache_device *);
drivers/md/bcache/super.c +6 -4
@@ -946,7 +946,8 @@ void bch_cached_dev_detach(struct cached_dev *dc)cached_dev_put (dc); } -int bch_cached_dev_attach (struct cached_dev *dc,struct cache_set *c) +int bch_cached_dev_attach (struct cached_dev *dc,struct cache_set *c, +uint8_t *set_uuid) {uint32_t rtime =cpu_to_le32 (get_seconds ());struct uuid_entry *u;
@@ -955,7 +956,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)bdevname (dc->bdev, buf); -if (memcmp (dc->sb.set_uuid, c->sb.set_uuid,16 )) +if ((set_uuid &&memcmp (set_uuid, c->sb.set_uuid,16 )) || + (!set_uuid &&memcmp (dc->sb.set_uuid, c->sb.set_uuid,16 )))return -ENOENT ;if (dc->disk.c) {
@@ -1194,7 +1196,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,list_add (&dc->list, &uncached_devices);list_for_each_entry (c, &bch_cache_sets, list) -bch_cached_dev_attach (dc, c); +bch_cached_dev_attach (dc, c,NULL );if (BDEV_STATE (&dc->sb) ==BDEV_STATE_NONE ||BDEV_STATE (&dc->sb) ==BDEV_STATE_STALE )
@@ -1716,7 +1718,7 @@ static void run_cache_set(struct cache_set *c)bcache_write_super (c);list_for_each_entry_safe (dc, t, &uncached_devices, list) -bch_cached_dev_attach (dc, c); +bch_cached_dev_attach (dc, c,NULL );flash_devs_run (c);
drivers/md/bcache/sysfs.c +4 -2
@@ -267,11 +267,13 @@ STORE(__cached_dev) }if (attr == &sysfs_attach) { -if (bch_parse_uuid (buf, dc->sb.set_uuid) <16 ) +uint8_t set_uuid[16 ]; + +if (bch_parse_uuid (buf, set_uuid) <16 )return -EINVAL ;list_for_each_entry (c, &bch_cache_sets, list) { - v =bch_cached_dev_attach (dc, c); + v =bch_cached_dev_attach (dc, c, set_uuid);if (!v)return size; }
Signature · 1 line
2.15.1
PATCH 163/189 bcache: return attach error when no cache set exist
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 7f4fc93d4713394ee8f1cd44c238e046e11b4f15 ]
I attach a back-end device to a cache set, and the cache set is not registered yet, this back-end device did not attach successfully, and no error returned:
[root]# echo 87859280-fec6-4bcc-20df7ca8f86b > /sys/block/sde/bcache/attach [root]#
In sysfs_attach(), the return value "v" is initialized to "size" in the beginning, and if no cache set exist in bch_cache_sets, the "v" value would not change any more, and return to sysfs, sysfs regard it as success since the "size" is a positive number.
This patch fixes this issue by assigning "v" with "-ENOENT" in the initialization.
--- drivers/md/bcache/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/bcache/sysfs.c +3 -2
@@ -195,7 +195,7 @@ STORE(__cached_dev) { struct cached_dev *dc = container_of(kobj, struct cached_dev, disk.kobj); -ssize_t v = size; +ssize_t v;struct cache_set *c;struct kobj_uevent_env *env;
@@ -272,6 +272,7 @@ STORE(__cached_dev)if (bch_parse_uuid (buf, set_uuid) <16 )return -EINVAL ; + v = -ENOENT ;list_for_each_entry (c, &bch_cache_sets, list) { v =bch_cached_dev_attach (dc, c, set_uuid);if (!v)
@@ -279,7 +280,7 @@ STORE(__cached_dev) }pr_err ("Can't attach %s: cache set not found" , buf); - size = v; +return v; }if (attr == &sysfs_detach && dc->disk.c)
Signature · 1 line
2.15.1
PATCH 164/189 rxrpc: Fix received abort handling
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 17e9e23b130e4e269fa53c2370325249f3ba75dd ]
AF_RXRPC is incorrectly sending back to the server any abort it receives for a client connection. This is due to the final-ACK offload to the connection event processor patch. The abort code is copied into the last-call information on the connection channel and then the event processor is set.
Instead, the following should be done:
(1) In the case of a final-ACK for a successful call, the ACK should be scheduled as before.
(2) In the case of a locally generated ABORT, the ABORT details should be cached for sending in response to further packets related to that call and no further action scheduled at call disconnect time.
(3) In the case of an ACK received from the peer, the call should be considered dead, no ABORT should be transmitted at this time. In response to further non-ABORT packets from the peer relating to this call, an RX_USER_ABORT ABORT should be transmitted.
(4) In the case of a call killed due to network error, an RX_USER_ABORT ABORT should be cached for transmission in response to further packets, but no ABORT should be sent at this time.
--- net/rxrpc/conn_client.c | 3 ++- net/rxrpc/conn_object.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
net/rxrpc/conn_client.c +2 -1
@@ -834,7 +834,8 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call)* can be skipped if we find a follow-on call. The first DATA packet * of the follow on call will implicitly ACK this call. */ -if (test_bit (RXRPC_CALL_EXPOSED , &call->flags)) { +if (call->completion ==RXRPC_CALL_SUCCEEDED && +test_bit (RXRPC_CALL_EXPOSED , &call->flags)) {unsigned long final_ack_at = jiffies +2 ;WRITE_ONCE (chan->final_ack_at, final_ack_at);
net/rxrpc/conn_object.c +12 -4
@@ -177,13 +177,21 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn,* through the channel, whilst disposing of the actual call record. */ trace_rxrpc_disconnect_call (call); -if (call->abort_code) { - chan->last_abort = call->abort_code; - chan->last_type =RXRPC_PACKET_TYPE_ABORT ; - }else { +switch (call->completion) { +case RXRPC_CALL_SUCCEEDED : chan->last_seq = call->rx_hard_ack; chan->last_type =RXRPC_PACKET_TYPE_ACK ; +break ; +case RXRPC_CALL_LOCALLY_ABORTED : + chan->last_abort = call->abort_code; + chan->last_type =RXRPC_PACKET_TYPE_ABORT ; +break ; +default : + chan->last_abort =RX_USER_ABORT ; + chan->last_type =RXRPC_PACKET_TYPE_ABORT ; +break ; } +/* Sync with rxrpc_conn_retransmit(). */ smp_wmb (); chan->last_call = chan->call_id;
Signature · 1 line
2.15.1
PATCH 165/189 sch_netem: Bug fixing in calculating Netem interval
In reply to Sasha LevinFrom: "Md. Islam" <[email protected]>
[ Upstream commit 043e337f555e610ad8237fd23522d97c968d72b9 ]
In Kernel 4.15.0+, Netem does not work properly.
Netem setup:
tc qdisc add dev h1-eth0 root handle 1: netem delay 10ms 2ms
Result:
PING 172.16.101.2 (172.16.101.2) 56(84) bytes of data. 64 bytes from 172.16.101.2: icmp_seq=1 ttl=64 time=22.8 ms 64 bytes from 172.16.101.2: icmp_seq=2 ttl=64 time=10.9 ms 64 bytes from 172.16.101.2: icmp_seq=3 ttl=64 time=10.9 ms 64 bytes from 172.16.101.2: icmp_seq=5 ttl=64 time=11.4 ms 64 bytes from 172.16.101.2: icmp_seq=6 ttl=64 time=11.8 ms 64 bytes from 172.16.101.2: icmp_seq=4 ttl=64 time=4303 ms 64 bytes from 172.16.101.2: icmp_seq=10 ttl=64 time=11.2 ms 64 bytes from 172.16.101.2: icmp_seq=11 ttl=64 time=10.3 ms 64 bytes from 172.16.101.2: icmp_seq=7 ttl=64 time=4304 ms 64 bytes from 172.16.101.2: icmp_seq=8 ttl=64 time=4303 ms
Patch:
(rnd % (2 * sigma)) - sigma was overflowing s32. After applying the patch, I found following output which is desirable.
PING 172.16.101.2 (172.16.101.2) 56(84) bytes of data. 64 bytes from 172.16.101.2: icmp_seq=1 ttl=64 time=21.1 ms 64 bytes from 172.16.101.2: icmp_seq=2 ttl=64 time=8.46 ms 64 bytes from 172.16.101.2: icmp_seq=3 ttl=64 time=9.00 ms 64 bytes from 172.16.101.2: icmp_seq=4 ttl=64 time=11.8 ms 64 bytes from 172.16.101.2: icmp_seq=5 ttl=64 time=8.36 ms 64 bytes from 172.16.101.2: icmp_seq=6 ttl=64 time=11.8 ms 64 bytes from 172.16.101.2: icmp_seq=7 ttl=64 time=8.11 ms 64 bytes from 172.16.101.2: icmp_seq=8 ttl=64 time=10.0 ms 64 bytes from 172.16.101.2: icmp_seq=9 ttl=64 time=11.3 ms 64 bytes from 172.16.101.2: icmp_seq=10 ttl=64 time=11.5 ms 64 bytes from 172.16.101.2: icmp_seq=11 ttl=64 time=10.2 ms
--- net/sched/sch_netem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_netem.c +1 -1
@@ -327,7 +327,7 @@ static s64 tabledist(s64 mu, s32 sigma,/* default uniform distribution */ if (dist ==NULL ) -return (rnd % (2 * sigma)) - sigma + mu; +return ((rnd % (2 * sigma)) + mu) - sigma; t = dist->table[rnd % dist->size]; x = (sigma %NETEM_DIST_SCALE ) * t;
Signature · 1 line
2.15.1
PATCH 166/189 cpufreq: intel_pstate: Enable HWP during system resume on CPU0
In reply to Sasha LevinFrom: Chen Yu <[email protected]>
[ Upstream commit 70f6bf2a3b7e40c3f802b0ea837762a8bc6c1430 ]
When maxcpus=1 is in the kernel command line, the BP is responsible for re-enabling the HWP - because currently only the APs invoke intel_pstate_hwp_enable() during their online process - which might put the system into unstable state after resume.
Fix this by enabling the HWP explicitly on BP during resume.
--- drivers/cpufreq/intel_pstate.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/cpufreq/intel_pstate.c +5 -0
@@ -779,6 +779,8 @@ static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)return 0 ; } +static void intel_pstate_hwp_enable (struct cpudata *cpudata); +static int intel_pstate_resume (struct cpufreq_policy *policy) {if (!hwp_active)
@@ -786,6 +788,9 @@ static int intel_pstate_resume(struct cpufreq_policy *policy)mutex_lock (&intel_pstate_limits_lock); +if (policy->cpu ==0 ) +intel_pstate_hwp_enable (all_cpu_data[policy->cpu]); + all_cpu_data[policy->cpu]->epp_policy =0 ;intel_pstate_hwp_set (policy->cpu);
Signature · 1 line
2.15.1
PATCH 167/189 selftests/ftrace: Add some missing glob checks
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
[ Upstream commit 97fe22adf33f06519bfdf7dad33bcd562e366c8f ]
Al Viro discovered a bug in the glob ftrace filtering code where "*a*b" is treated the same as "a*b", and functions that would be selected by "*a*b" but not "a*b" are not selected with "*a*b".
Add tests for patterns "*a*b" and "a*b*" to the glob selftest.
--- tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +6 -0
@@ -29,6 +29,12 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$' # filter by *, end match ftrace_filter_check 'schedule*' '^schedule.*$' +# filter by *mid*end +ftrace_filter_check '*aw*lock' '.*aw.*lock$' + +# filter by start*mid* +ftrace_filter_check 'mutex*try*' '^mutex.*try.*' + # Advanced full-glob matching feature is recently supported. # Skip the tests if we are sure the kernel does not support it. if grep -q 'accepts: .* glob-matching-pattern' README ; then
Signature · 1 line
2.15.1
PATCH 168/189 nfsd: return RESOURCE not GARBAGE_ARGS on too many ops
In reply to Sasha LevinFrom: "J. Bruce Fields" <[email protected]>
[ Upstream commit 0078117c6d9160031b866cfa1853514d4f6865d2 ]
A client that sends more than a hundred ops in a single compound currently gets an rpc-level GARBAGE_ARGS error.
It would be more helpful to return NFS4ERR_RESOURCE, since that gives the client a better idea how to recover (for example by splitting up the compound into smaller compounds).
This is all a bit academic since we've never actually seen a reason for clients to send such long compounds, but we may as well fix it.
While we're there, just use NFSD4_MAX_OPS_PER_COMPOUND == 16, the constant we already use in the 4.1 case, instead of hard-coding 100. Chances anyone actually uses even 16 ops per compound are small enough that I think there's a neglible risk or any regression.
This fixes pynfs test COMP6.
--- fs/nfsd/nfs4proc.c | 3 +++ fs/nfsd/nfs4xdr.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -0
@@ -1703,6 +1703,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) status = nfserr_minor_vers_mismatch;if (nfsd_minorversion (args->minorversion,NFSD_TEST ) <=0 ) goto out; + status = nfserr_resource; +if (args->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) + goto out; status =nfs41_check_op_ordering (args);if (status) {
fs/nfsd/nfs4xdr.c +7 -2
@@ -1918,8 +1918,13 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)if (argp->taglen >NFSD4_MAX_TAGLEN ) goto xdr_error; -if (argp->opcnt >100 ) - goto xdr_error; +/* +* NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS +* here, so we return success at the xdr level so that +* nfsd4_proc can handle this is an NFS-level error. +*/ +if (argp->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) +return 0 ;if (argp->opcnt >ARRAY_SIZE (argp->iops)) { argp->ops =kzalloc (argp->opcnt *sizeof (*argp->ops),GFP_KERNEL );
Signature · 1 line
2.15.1
Re: [PATCH AUTOSEL for 4.15 168/189] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops
What's your default on these patches on these AUTOSEL patches if you don't get an ACK or NACK? Do you apply them anyway?
(I'd skip this one as it doesn't meet the "It must fix a real bug that bothers people" criterion. But I don't recall it *causing* any bugs either, so the stakes are low, I'm mainly just curious.)
--b.
Quoted 65 lines · Sasha Levin
From: "J. Bruce Fields" <[email protected]>
[ Upstream commit
0078117c6d9160031b866cfa1853514d4f6865d2]A client that sends more than a hundred ops in a single compound currently gets an rpc-level
GARBAGE_ARGSerror.It would be more helpful to return
NFS4ERR_RESOURCE, since that gives the client a better idea how to recover (for example by splitting up the compound into smaller compounds).This is all a bit academic since we've never actually seen a reason for clients to send such long compounds, but we may as well fix it.
While we're there, just use
NFSD4_MAX_OPS_PER_COMPOUND== 16, the constant we already use in the 4.1 case, instead of hard-coding 100. Chances anyone actually uses even 16 ops per compound are small enough that I think there's a neglible risk or any regression.This fixes pynfs test COMP6.
Reported-by "Lu, Xinyu" <[email protected]>Signed-off-by J. Bruce Fields <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/nfsd/nfs4proc.c | 3 +++ fs/nfsd/nfs4xdr.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)fs/nfsd/nfs4proc.c +3
-0@@ -1703,6 +1703,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) status = nfserr_minor_vers_mismatch;if (nfsd_minorversion (args->minorversion,NFSD_TEST ) <=0 ) goto out; + status = nfserr_resource; +if (args->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) + goto out; status =nfs41_check_op_ordering (args);if (status) {fs/nfsd/nfs4xdr.c +7
-2@@ -1918,8 +1918,13 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)if (argp->taglen >NFSD4_MAX_TAGLEN ) goto xdr_error; -if (argp->opcnt >100 ) - goto xdr_error; +/* +* NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS +* here, so we return success at the xdr level so that +* nfsd4_proc can handle this is an NFS-level error. +*/ +if (argp->opcnt >NFSD_MAX_OPS_PER_COMPOUND ) +return 0 ;if (argp->opcnt >ARRAY_SIZE (argp->iops)) { argp->ops =kzalloc (argp->opcnt *sizeof (*argp->ops),GFP_KERNEL );Signature · 1 line
2.15.1
Re: [PATCH AUTOSEL for 4.15 168/189] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops
Quoted 2 lines · J. Bruce Fields
What's your default on these patches on these AUTOSEL patches if you don't get an ACK or NACK? Do you apply them anyway?
Right now it's opt-out, so it'll get merged unless you NACK it.
In general, these patches get higher visibility as a notice will be sent a few times for each of these, when:
1. I added it to my queue
2. When Greg sends his review cycle
3. Once a stable kernel is released
Quoted 3 lines
(I'd skip this one as it doesn't meet the "It must fix a real bug that bothers people" criterion. But I don't recall it *causing* any bugs either, so the stakes are low, I'm mainly just curious.)
I'll drop it, thanks!
Re: [PATCH AUTOSEL for 4.15 168/189] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops
Quoted 4 lines · Sasha Levin
Quoted 2 lines · J. Bruce Fields
What's your default on these patches on these AUTOSEL patches if you don't get an ACK or NACK? Do you apply them anyway?
Quoted 8 lines
Right now it's opt-out, so it'll get merged unless you NACK it.
In general, these patches get higher visibility as a notice will be sent a few times for each of these, when:
1. I added it to my queue
2. When Greg sends his review cycle
3. Once a stable kernel is released
OK, thanks for the explanation!
--b.
PATCH 169/189 rxrpc: Don't put crypto buffers on the stack
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 8c2f826dc36314059ac146c78d3bf8056b626446 ]
Don't put buffers of data to be handed to crypto on the stack as this may cause an assertion failure in the kernel (see below). Fix this by using an kmalloc'd buffer instead.
kernel BUG at ./include/linux/scatterlist.h:147!
...
RIP: 0010:rxkad_encrypt_response.isra.6+0x191/0x1b0 [rxrpc] RSP: 0018:ffffbe2fc06cfca8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff989277d59900 RCX: 0000000000000028 RDX: 0000259dc06cfd88 RSI: 0000000000000025 RDI: ffffbe30406cfd88 RBP: ffffbe2fc06cfd60 R08: ffffbe2fc06cfd08 R09: ffffbe2fc06cfd08 R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff7c5f80d9f95 R13: ffffbe2fc06cfd88 R14: ffff98927a3f7aa0 R15: ffffbe2fc06cfd08 FS: 0000000000000000(0000) GS:ffff98927fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055b1ff28f0f8 CR3: 000000001b412003 CR4: 00000000003606f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: rxkad_respond_to_challenge+0x297/0x330 [rxrpc] rxrpc_process_connection+0xd1/0x690 [rxrpc] ? process_one_work+0x1c3/0x680 ? __lock_is_held+0x59/0xa0 process_one_work+0x249/0x680 worker_thread+0x3a/0x390 ? process_one_work+0x680/0x680 kthread+0x121/0x140 ? kthread_create_worker_on_cpu+0x70/0x70 ret_from_fork+0x3a/0x50
--- net/rxrpc/conn_event.c | 1 + net/rxrpc/rxkad.c | 92 ++++++++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 41 deletions(-)
net/rxrpc/conn_event.c +1 -0
@@ -460,6 +460,7 @@ void rxrpc_process_connection(struct work_struct *work)case -EKEYEXPIRED :case -EKEYREJECTED : goto protocol_error; +case -ENOMEM :case -EAGAIN : goto requeue_and_leave;case -ECONNABORTED :
net/rxrpc/rxkad.c +51 -41
174 lines not on this page · raw message
Signature · 1 line
2.15.1
PATCH 170/189 svcrdma: Fix Read chunk round-up
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 175e03101d36c3034f3c80038d4c28838351a7f2 ]
A single NFSv4 WRITE compound can often have three operations:
PUTFH, WRITE, then GETATTR.
When the WRITE payload is sent in a Read chunk, the client places the GETATTR in the inline part of the RPC/RDMA message, just after the WRITE operation (sans payload). The position value in the Read chunk enables the receiver to insert the Read chunk at the correct place in the received XDR stream; that is between the WRITE and GETATTR.
According to RFC 8166, an NFS/RDMA client does not have to add XDR round-up to the Read chunk that carries the WRITE payload. The receiver adds XDR round-up padding if it is absent and the receiver's XDR decoder requires it to be present.
Commit 193bcb7b3719 ("svcrdma: Populate tail iovec when receiving") attempted to add support for receiving such a compound so that just the WRITE payload appears in rq_arg's page list, and the trailing GETATTR is placed in rq_arg's tail iovec. (TCP just strings the whole compound into the head iovec and page list, without regard to the alignment of the WRITE payload).
The server transport logic also had to accommodate the optional XDR round-up of the Read chunk, which it did simply by lengthening the tail iovec when round-up was needed. This approach is adequate for the NFSv2 and NFSv3 WRITE decoders.
Unfortunately it is not sufficient for nfsd4_decode_write. When the Read chunk length is a couple of bytes less than PAGE_SIZE, the computation at the end of nfsd4_decode_write allows argp->pagelen to go negative, which breaks the logic in read_buf that looks for the tail iovec.
The result is that a WRITE operation whose payload length is just less than a multiple of a page succeeds, but the subsequent GETATTR in the same compound fails with NFS4ERR_OP_ILLEGAL because the XDR decoder can't find it. Clients ignore the error, but they must update their attribute cache via a separate round trip.
As nfsd4_decode_write appears to expect the payload itself to always have appropriate XDR round-up, have svc_rdma_build_normal_read_chunk add the Read chunk XDR round-up to the page_len rather than lengthening the tail iovec.
--- net/sunrpc/xprtrdma/svc_rdma_rw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_rw.c +8 -4
@@ -727,12 +727,16 @@ static int svc_rdma_build_normal_read_chunk(struct svc_rqst *rqstp, head->arg.head[0 ].iov_len - info->ri_position; head->arg.head[0 ].iov_len = info->ri_position; -/* Read chunk may need XDR roundup (see RFC 5666, s. 3.7). +/* Read chunk may need XDR roundup (see RFC 8166, s. 3.4.5.2). * -* NFSv2/3 write decoders need the length of the tail to -* contain the size of the roundup padding. +* If the client already rounded up the chunk length, the +* length does not change. Otherwise, the length of the page +* list is increased to include XDR round-up. +* +* Currently these chunks always start at page offset 0, +* thus the rounded-up length never crosses a page boundary. */ - head->arg.tail[0 ].iov_len +=4 - (info->ri_chunklen &3 ); + info->ri_chunklen =XDR_QUADLEN (info->ri_chunklen) <<2 ; head->arg.page_len = info->ri_chunklen; head->arg.len += info->ri_chunklen;
Signature · 1 line
2.15.1
PATCH 171/189 net: Extra '_get' in declaration of arch_get_platform_mac_address
In reply to Sasha LevinFrom: Mathieu Malaterre <[email protected]>
[ Upstream commit e728789c52afccc1275cba1dd812f03abe16ea3c ]
In commit c7f5d105495a ("net: Add eth_platform_get_mac_address() helper."), two declarations were added:
int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr); unsigned char *arch_get_platform_get_mac_address(void);
An extra '_get' was introduced in arch_get_platform_get_mac_address, remove it. Fix compile warning using W=1:
CC net/ethernet/eth.onet/ethernet/eth.c:523:24: warning: no previous prototype for ‘arch_get_platform_mac_address’ [-Wmissing-prototypes]
unsigned char * __weak arch_get_platform_mac_address(void)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AR net/ethernet/built-in.o
--- include/linux/etherdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/etherdevice.h +1 -1
@@ -31,7 +31,7 @@#ifdef __KERNEL__struct device ;int eth_platform_get_mac_address (struct device *dev,u8 *mac_addr); -unsigned char *arch_get_platform_get_mac_address (void ); +unsigned char *arch_get_platform_mac_address (void );u32 eth_get_headlen (void *data,unsigned int max_len);__be16 eth_type_trans (struct sk_buff *skb,struct net_device *dev);extern const struct header_ops eth_header_ops;
Signature · 1 line
2.15.1
PATCH 172/189 tipc: fix skb truesize/datasize ratio control
In reply to Sasha LevinFrom: Hoang Le <[email protected]>
[ Upstream commit 55b3280d1e471795c08dbbe17325720a843e104c ]
In commit d618d09a68e4 ("tipc: enforce valid ratio between skb truesize and contents") we introduced a test for ensuring that the condition truesize/datasize <= 4 is true for a received buffer. Unfortunately this test has two problems.
- Because of the integer arithmetics the test
if (skb->truesize / buf_roundup_len(skb) > 4) will miss all ratios [4 < ratio < 5], which was not the intention.
- The buffer returned by skb_copy() inherits skb->truesize of the original buffer, which doesn't help the situation at all.
In this commit, we change the ratio condition and replace skb_copy() with a call to skb_copy_expand() to finally get this right.
--- net/tipc/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tipc/msg.c +2 -2
@@ -208,8 +208,8 @@ bool tipc_msg_validate(struct sk_buff **_skb)int msz, hsz;/* Ensure that flow control ratio condition is satisfied */ -if (unlikely (skb->truesize /buf_roundup_len (skb) >4 )) { - skb =skb_copy (skb,GFP_ATOMIC ); +if (unlikely (skb->truesize /buf_roundup_len (skb) >=4 )) { + skb =skb_copy_expand (skb,BUF_HEADROOM ,0 ,GFP_ATOMIC );if (!skb)return false;kfree_skb (*_skb);
Signature · 1 line
2.15.1
PATCH 173/189 tools/libbpf: handle issues with bpf ELF objects containing .eh_frames
In reply to Sasha LevinFrom: Jesper Dangaard Brouer <[email protected]>
[ Upstream commit e3d91b0ca523d53158f435a3e13df7f0cb360ea2 ]
V3: More generic skipping of relo-section (suggested by Daniel)
If clang >= 4.0.1 is missing the option '-target bpf', it will cause llc/llvm to create two ELF sections for "Exception Frames", with section names '.eh_frame' and '.rel.eh_frame'.
The BPF ELF loader library libbpf fails when loading files with these sections. The other in-kernel BPF ELF loader in samples/bpf/bpf_load.c, handle this gracefully. And iproute2 loader also seems to work with these "eh" sections.
The issue in libbpf is caused by bpf_object__elf_collect() skipping some sections, and later when performing relocation it will be pointing to a skipped section, as these sections cannot be found by bpf_object__find_prog_by_idx() in bpf_object__collect_reloc().
This is a general issue that also occurs for other sections, like debug sections which are also skipped and can have relo section.
As suggested by Daniel. To avoid keeping state about all skipped sections, instead perform a direct qlookup in the ELF object. Lookup the section that the relo-section points to and check if it contains executable machine instructions (denoted by the sh_flags SHF_EXECINSTR). Use this check to also skip irrelevant relo-sections.
Note, for samples/bpf/ the '-target bpf' parameter to clang cannot be used due to incompatibility with asm embedded headers, that some of the samples include. This is explained in more details by Yonghong Song in bpf_devel_QA.
--- tools/lib/bpf/libbpf.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tools/lib/bpf/libbpf.c +26 -0
@@ -726,6 +726,24 @@ bpf_object__init_maps(struct bpf_object *obj)return 0 ; } +static bool section_have_execinstr (struct bpf_object *obj,int idx) +{ +Elf_Scn *scn; +GElf_Shdr sh; + + scn =elf_getscn (obj->efile.elf, idx); +if (!scn) +return false; + +if (gelf_getshdr (scn, &sh) != &sh) +return false; + +if (sh.sh_flags &SHF_EXECINSTR ) +return true; + +return false; +} +static int bpf_object__elf_collect (struct bpf_object *obj) {Elf *elf = obj->efile.elf;
@@ -807,6 +825,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj) }else if (sh.sh_type ==SHT_REL ) {void *reloc = obj->efile.reloc;int nr_reloc = obj->efile.nr_reloc +1 ; +int sec = sh.sh_info;/* points to other section */ + +/* Only do relo for section with exec instructions */ +if (!section_have_execinstr (obj, sec)) { +pr_debug ("skip relo %s(%d) for section(%d)\n" , + name, idx, sec); +continue ; + } reloc =realloc (reloc,sizeof (*obj->efile.reloc) * nr_reloc);
Signature · 1 line
2.15.1
PATCH 174/189 KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code
In reply to Sasha LevinFrom: Paul Mackerras <[email protected]>
[ Upstream commit 05f2bb0313a2855e491dadfc8319b7da261d7074 ]
This fixes the computation of the HPTE index to use when the HPT resizing code encounters a bolted HPTE which is stored in its secondary HPTE group. The code inverts the HPTE group number, which is correct, but doesn't then mask it with new_hash_mask. As a result, new_pteg will be effectively negative, resulting in new_hptep pointing before the new HPT, which will corrupt memory.
In addition, this removes two BUG_ON statements. The condition that the BUG_ONs were testing -- that we have computed the hash value incorrectly -- has never been observed in testing, and if it did occur, would only affect the guest, not the host. Given that BUG_ON should only be used in conditions where the kernel (i.e. the host kernel, in this case) can't possibly continue execution, it is not appropriate here.
--- arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +2 -6
@@ -1337,12 +1337,8 @@ static unsigned long resize_hpt_rehash_hpte(struct kvm_resize_hpt *resize, } new_pteg = hash & new_hash_mask; -if (vpte &HPTE_V_SECONDARY ) { -BUG_ON (~pteg != (hash & old_hash_mask)); - new_pteg = ~new_pteg; - }else { -BUG_ON (pteg != (hash & old_hash_mask)); - } +if (vpte &HPTE_V_SECONDARY ) + new_pteg = ~hash & new_hash_mask; new_idx = new_pteg *HPTES_PER_GROUP + (idx %HPTES_PER_GROUP ); new_hptep = (__be64 *)(new->virt + (new_idx <<4 ));
Signature · 1 line
2.15.1
PATCH 175/189 ibmvnic: Reset long term map ID counter
In reply to Sasha LevinFrom: Thomas Falcon <[email protected]>
[ Upstream commit faefaa97215a0c05105d7ae180fe1a3b5979ad1f ]
When allocating RX or TX buffer pools, the driver needs to provide a unique mapping ID to firmware for each pool. This value is assigned using a counter which is incremented after a new pool is created. The ID can be an integer ranging from 1-255. When migrating to a device that requests a different number of queues, this value was not being reset properly. As a result, after enough migrations, the counter exceeded the upper bound and pool creation failed. This is fixed by resetting the counter to one in this case.
--- drivers/net/ethernet/ibm/ibmvnic.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ibm/ibmvnic.c +1 -0
@@ -1634,6 +1634,7 @@ static int do_reset(struct ibmvnic_adapter *adapter,return rc; }else if (adapter->req_rx_queues != old_num_rx_queues || adapter->req_tx_queues != old_num_tx_queues) { + adapter->map_id =1 ;release_rx_pools (adapter);release_tx_pools (adapter);init_rx_pools (netdev);
Signature · 1 line
2.15.1
PATCH 176/189 SUNRPC: Don't call __UDPX_INC_STATS() from a preemptible context
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit 0afa6b4412988019db14c6bfb8c6cbdf120ca9ad ]
Calling __UDPX_INC_STATS() from a preemptible context leads to a warning of the form:
BUG: using __this_cpu_add() in preemptible [00000000] code: kworker/u5:0/31 caller is xs_udp_data_receive_workfn+0x194/0x270 CPU: 1 PID: 31 Comm: kworker/u5:0 Not tainted 4.15.0-rc8-00076-g90ea9f1 #2 Workqueue: xprtiod xs_udp_data_receive_workfn Call Trace: dump_stack+0x85/0xc1 check_preemption_disabled+0xce/0xe0 xs_udp_data_receive_workfn+0x194/0x270 process_one_work+0x318/0x620 worker_thread+0x20a/0x390 ? process_one_work+0x620/0x620 kthread+0x120/0x130 ? __kthread_bind_mask+0x60/0x60 ret_from_fork+0x24/0x30
Since we're taking a spinlock in those functions anyway, let's fix the issue by moving the call so that it occurs under the spinlock.
--- net/sunrpc/xprtsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/xprtsock.c +2 -2
@@ -1070,18 +1070,18 @@ static void xs_udp_data_read_skb(struct rpc_xprt *xprt,/* Suck it into the iovec, verify checksum if not done by hw. */ if (csum_partial_copy_to_xdr (&rovr->rq_private_buf, skb)) { -__UDPX_INC_STATS (sk,UDP_MIB_INERRORS );spin_lock (&xprt->recv_lock); +__UDPX_INC_STATS (sk,UDP_MIB_INERRORS ); goto out_unpin; } -__UDPX_INC_STATS (sk,UDP_MIB_INDATAGRAMS );spin_lock_bh (&xprt->transport_lock);xprt_adjust_cwnd (xprt, task, copied);spin_unlock_bh (&xprt->transport_lock);spin_lock (&xprt->recv_lock);xprt_complete_rqst (task, copied); +__UDPX_INC_STATS (sk,UDP_MIB_INDATAGRAMS ); out_unpin:xprt_unpin_rqst (rovr); out_unlock:
Signature · 1 line
2.15.1
PATCH 177/189 net: stmmac: discard disabled flags in interrupt status register
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 1b84ca187510f60f00f4e15255043ce19bb30410 ]
The interrupt status register in both dwmac1000 and dwmac4 ignores interrupt enable (for dwmac4) / interrupt mask (for dwmac1000). Therefore, if we want to check only the bits that can actually trigger an irq, we have to filter the interrupt status register manually.
Commit 0a764db10337 ("stmmac: Discard masked flags in interrupt status register") fixed this for dwmac1000. Fix the same issue for dwmac4.
Just like commit 0a764db10337 ("stmmac: Discard masked flags in interrupt status register"), this makes sure that we do not get spurious link up/link down prints.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +4 -2
@@ -562,10 +562,12 @@ static int dwmac4_irq_status(struct mac_device_info *hw, struct stmmac_extra_stats *x) {void __iomem *ioaddr = hw->pcsr; -u32 intr_status; +u32 intr_status =readl (ioaddr +GMAC_INT_STATUS ); +u32 intr_enable =readl (ioaddr +GMAC_INT_EN );int ret =0 ; - intr_status =readl (ioaddr +GMAC_INT_STATUS ); +/* Discard disabled bits */ + intr_status &= intr_enable;/* Not used events (e.g. MMC interrupts) are not handled. */ if ((intr_status & mmc_tx_irq))
Signature · 1 line
2.15.1
PATCH 178/189 bpf: fix rlimit in reuseport net selftest
In reply to Sasha LevinFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 941ff6f11c020913f5cddf543a9ec63475d7c082 ]
Fix two issues in the reuseport_bpf selftests that were reported by Linaro CI:
[...]
+ ./reuseport_bpf
---- IPv4 UDP ----
Testing EBPF mod 10...
Reprograming, testing mod 5...
./reuseport_bpf: ebpf error. log:
0: (bf) r6 = r1
1: (20) r0 = *(u32 *)skb[0]
2: (97) r0 %= 10
3: (95) exit
processed 4 insns
: Operation not permitted
+ echo FAIL
[...]
---- IPv4 TCP ----
Testing EBPF mod 10...
./reuseport_bpf: failed to bind send socket: Address already in use
+ echo FAIL
[...]
For the former adjust rlimit since this was the cause of failure for loading the BPF prog, and for the latter add SO_REUSEADDR.
--- tools/testing/selftests/net/reuseport_bpf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
tools/testing/selftests/net/reuseport_bpf.c +20 -1
@@ -21,6 +21,7 @@#include <sys/epoll.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/resource.h> #include <unistd.h> #ifndef ARRAY_SIZE
@@ -190,11 +191,14 @@ static void send_from(struct test_params p, uint16_t sport, char *buf,struct sockaddr *const saddr =new_any_sockaddr (p.send_family, sport);struct sockaddr *const daddr =new_loopback_sockaddr (p.send_family, p.recv_port); -const int fd =socket (p.send_family, p.protocol,0 ); +const int fd =socket (p.send_family, p.protocol,0 ), one =1 ;if (fd <0 )error (1 , errno,"failed to create send socket" ); +if (setsockopt (fd,SOL_SOCKET ,SO_REUSEADDR , &one,sizeof (one))) +error (1 , errno,"failed to set reuseaddr" ); +if (bind (fd, saddr,sockaddr_size ()))error (1 , errno,"failed to bind send socket" );
@@ -433,6 +437,21 @@ void enable_fastopen(void) } } +static struct rlimit rlim_old, rlim_new; + +static __attribute__((constructor))void main_ctor (void ) +{ +getrlimit (RLIMIT_MEMLOCK , &rlim_old); + rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL <<20 ); + rlim_new.rlim_max = rlim_old.rlim_max + (1UL <<20 ); +setrlimit (RLIMIT_MEMLOCK , &rlim_new); +} + +static __attribute__((destructor))void main_dtor (void ) +{ +setrlimit (RLIMIT_MEMLOCK , &rlim_old); +} +int main (void ) {fprintf (stderr,"---- IPv4 UDP ----\n" );
Signature · 1 line
2.15.1
PATCH 179/189 ACPI / EC: Restore polling during noirq suspend/resume phases
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 3cd091a773936c54344a519f7ee1379ccb620bee ]
Commit 662591461c4b (ACPI / EC: Drop EC noirq hooks to fix a regression) modified the ACPI EC driver so that it doesn't switch over to busy polling mode during noirq stages of system suspend and resume in an attempt to fix an issue resulting from that behavior.
However, that modification introduced a system resume regression on Thinkpad X240, so make the EC driver switch over to the polling mode during noirq stages of system suspend and resume again, which effectively reverts the problematic commit.
--- drivers/acpi/ec.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/acpi/ec.c +6 -0
@@ -1927,6 +1927,9 @@ static int acpi_ec_suspend_noirq(struct device *dev) ec->reference_count >= 1)acpi_set_gpe (NULL , ec->gpe,ACPI_GPE_DISABLE ); +if (acpi_sleep_no_ec_events ()) +acpi_ec_enter_noirq (ec); +return 0 ; }
@@ -1934,6 +1937,9 @@ static int acpi_ec_resume_noirq(struct device *dev) {struct acpi_ec *ec =acpi_driver_data (to_acpi_device (dev)); +if (acpi_sleep_no_ec_events ()) +acpi_ec_leave_noirq (ec); +if (ec_no_wakeup &&test_bit (EC_FLAGS_STARTED , &ec->flags) && ec->reference_count >=1 )acpi_set_gpe (NULL , ec->gpe,ACPI_GPE_ENABLE );
Signature · 1 line
2.15.1
PATCH 180/189 PM / wakeirq: Fix unbalanced IRQ enable for wakeirq
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 69728051f5bf15efaf6edfbcfe1b5a49a2437918 ]
If a device is runtime PM suspended when we enter suspend and has a dedicated wake IRQ, we can get the following warning:
WARNING: CPU: 0 PID: 108 at kernel/irq/manage.c:526 enable_irq+0x40/0x94 [ 102.087860] Unbalanced enable for IRQ 147
...
(enable_irq) from [<c06117a8>] (dev_pm_arm_wake_irq+0x4c/0x60) (dev_pm_arm_wake_irq) from [<c0618360>]
(device_wakeup_arm_wake_irqs+0x58/0x9c)
(device_wakeup_arm_wake_irqs) from [<c0615948>] (dpm_suspend_noirq+0x10/0x48)
(dpm_suspend_noirq) from [<c01ac7ac>] (suspend_devices_and_enter+0x30c/0xf14) (suspend_devices_and_enter) from [<c01adf20>] (enter_state+0xad4/0xbd8)
(enter_state) from [<c01ad3ec>] (pm_suspend+0x38/0x98) (pm_suspend) from [<c01ab3e8>] (state_store+0x68/0xc8)
This is because the dedicated wake IRQ for the device may have been already enabled earlier by dev_pm_enable_wake_irq_check(). Fix the issue by checking for runtime PM suspended status.
This issue can be easily reproduced by setting serial console log level to zero, letting the serial console idle, and suspend the system from an ssh terminal. On resume, dmesg will have the warning above.
The reason why I have not run into this issue earlier has been that I typically run my PM test cases from on a serial console instead over ssh.
--- drivers/base/power/wakeirq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/power/wakeirq.c +4 -2
@@ -323,7 +323,8 @@ void dev_pm_arm_wake_irq(struct wake_irq *wirq)return ;if (device_may_wakeup (wirq->dev)) { -if (wirq->status &WAKE_IRQ_DEDICATED_ALLOCATED ) +if (wirq->status &WAKE_IRQ_DEDICATED_ALLOCATED && + !pm_runtime_status_suspended (wirq->dev))enable_irq (wirq->irq);enable_irq_wake (wirq->irq);
@@ -345,7 +346,8 @@ void dev_pm_disarm_wake_irq(struct wake_irq *wirq)if (device_may_wakeup (wirq->dev)) {disable_irq_wake (wirq->irq); -if (wirq->status &WAKE_IRQ_DEDICATED_ALLOCATED ) +if (wirq->status &WAKE_IRQ_DEDICATED_ALLOCATED && + !pm_runtime_status_suspended (wirq->dev))disable_irq_nosync (wirq->irq); } }
Signature · 1 line
2.15.1
PATCH 181/189 vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page
In reply to Sasha LevinFrom: Jia Zhang <[email protected]>
[ Upstream commit 595dd46ebfc10be041a365d0a3fa99df50b6ba73 ]
Commit:
df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext data")
... introduced a bounce buffer to work around CONFIG_HARDENED_USERCOPY=y. However, accessing the vsyscall user page will cause an SMAP fault.
Replace memcpy() with copy_from_user() to fix this bug works, but adding a common way to handle this sort of user page may be useful for future.
Currently, only vsyscall page requires KCORE_USER.
--- arch/x86/mm/init_64.c | 3 +-- fs/proc/kcore.c | 4 ++++ include/linux/kcore.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/mm/init_64.c +1 -2
@@ -1186,8 +1186,7 @@ void __init mem_init(void)register_page_bootmem_info ();/* Register memory areas for /proc/kcore */ -kclist_add (&kcore_vsyscall, (void *)VSYSCALL_ADDR , -PAGE_SIZE ,KCORE_OTHER ); +kclist_add (&kcore_vsyscall, (void *)VSYSCALL_ADDR ,PAGE_SIZE ,KCORE_USER );mem_init_print_info (NULL ); }
fs/proc/kcore.c +4 -0
@@ -510,6 +510,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)/* we have to zero-fill user buffer even if no read */ if (copy_to_user (buffer, buf, tsz))return -EFAULT ; + }else if (m->type ==KCORE_USER ) { +/* User page is handled prior to normal kernel page: */ +if (copy_to_user (buffer, (char *)start, tsz)) +return -EFAULT ; }else {if (kern_addr_valid (start)) {/*
include/linux/kcore.h +1 -0
@@ -10,6 +10,7 @@ enum kcore_type {KCORE_VMALLOC ,KCORE_RAM ,KCORE_VMEMMAP , +KCORE_USER , KCORE_OTHER, };
Signature · 1 line
2.15.1
PATCH 183/189 x86/platform/UV: Fix GAM Range Table entries less than 1GB
In reply to Sasha LevinFrom: "[email protected]" <[email protected]>
[ Upstream commit c25d99d20ba69824a1e2cc118e04b877cd427afc ]
The latest UV platforms include the new ApachePass NVDIMMs into the UV address space. This has introduced address ranges in the Global Address Map Table that are less than the previous lowest range, which was 2GB. Fix the address calculation so it accommodates address ranges from bytes to exabytes.
--- arch/x86/kernel/apic/x2apic_uv_x.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/x2apic_uv_x.c +12 -3
@@ -1174,16 +1174,25 @@ static void __init decode_gam_rng_tbl(unsigned long ptr) uv_gre_table = gre;for (; gre->type !=UV_GAM_RANGE_TYPE_UNUSED ; gre++) { +unsigned long size = ((unsigned long )(gre->limit - lgre) + <<UV_GAM_RANGE_SHFT ); +int order =0 ; +char suffix[] =" KMGTPE" ; + +while (size >9999 && order <sizeof (suffix)) { + size /=1024 ; + order++; + } +if (!index) {pr_info ("UV: GAM Range Table...\n" );pr_info ("UV: # %20s %14s %5s %4s %5s %3s %2s\n" ,"Range" ,"" ,"Size" ,"Type" ,"NASID" ,"SID" ,"PN" ); } -pr_info ("UV: %2d: 0x%014lx-0x%014lx %5luG %3d %04x %02x %02x\n" , +pr_info ("UV: %2d: 0x%014lx-0x%014lx %5lu%c %3d %04x %02x %02x\n" , index++, (unsigned long )lgre <<UV_GAM_RANGE_SHFT , (unsigned long )gre->limit <<UV_GAM_RANGE_SHFT , - ((unsigned long )(gre->limit - lgre)) >> - (30 -UV_GAM_RANGE_SHFT ),/* 64M -> 1G */ + size, suffix[order], gre->type, gre->nasid, gre->sockid, gre->pnode); lgre = gre->limit;
Signature · 1 line
2.15.1
PATCH 184/189 locking/qspinlock: Ensure node->count is updated before initialising node
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit 11dc13224c975efcec96647a4768a6f1bb7a19a8 ]
When queuing on the qspinlock, the count field for the current CPU's head node is incremented. This needn't be atomic because locking in e.g. IRQ context is balanced and so an IRQ will return with node->count as it found it.
However, the compiler could in theory reorder the initialisation of node[idx] before the increment of the head node->count, causing an IRQ to overwrite the initialised node and potentially corrupt the lock state.
Avoid the potential for this harmful compiler reordering by placing a barrier() between the increment of the head node->count and the subsequent node initialisation.
--- kernel/locking/qspinlock.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/locking/qspinlock.c +8 -0
@@ -379,6 +379,14 @@ queue: tail =encode_tail (smp_processor_id (), idx); node += idx; + +/* +* Ensure that we increment the head node->count before initialising +* the actual node. If the compiler is kind enough to reorder these +* stores, then an IRQ could overwrite our assignments. +*/ +barrier (); + node->locked =0 ; node->next =NULL ;pv_init_node (node);
Signature · 1 line
2.15.1
PATCH 185/189 powerpc/powernv: IMC fix out of bounds memory access at shutdown
In reply to Sasha LevinFrom: Nicholas Piggin <[email protected]>
[ Upstream commit e7bde88cdb4f0e432398a7d29ca2a15d2c18952a ]
The OPAL IMC driver's shutdown handler disables nest PMU counters by walking nodes and taking the first CPU out of their cpumask, which is used to index into the paca (get_hard_smp_processor_id()). This does not always do the right thing, and in particular for CPU-less nodes it returns NR_CPUS and that overruns the paca and dereferences random memory.
Fix it by being more careful about checking returned CPU, and only using online CPUs. It's not clear this shutdown code makes sense after commit 885dcd709b ("powerpc/perf: Add nest IMC PMU support"), but this should not make things worse
Currently the bug causes us to call OPAL with a junk CPU number. A separate patch in development to change the way pacas are allocated escalates this bug into a crash:
Unable to handle kernel paging request for data at address 0x2a21af1eeb000076 Faulting instruction address: 0xc0000000000a5468 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP opal_imc_counters_shutdown+0x148/0x1d0 LR opal_imc_counters_shutdown+0x134/0x1d0 Call Trace: opal_imc_counters_shutdown+0x134/0x1d0 (unreliable) platform_drv_shutdown+0x44/0x60 device_shutdown+0x1f8/0x350 kernel_restart_prepare+0x54/0x70 kernel_restart+0x28/0xc0 SyS_reboot+0x1d0/0x2c0 system_call+0x58/0x6c
--- arch/powerpc/platforms/powernv/opal-imc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/platforms/powernv/opal-imc.c +4 -2
@@ -126,9 +126,11 @@ static void disable_nest_pmu_counters(void)const struct cpumask *l_cpumask;get_online_cpus (); -for_each_online_node (nid) { +for_each_node_with_cpus (nid) { l_cpumask =cpumask_of_node (nid); - cpu =cpumask_first (l_cpumask); + cpu =cpumask_first_and (l_cpumask, cpu_online_mask); +if (cpu >= nr_cpu_ids) +continue ;opal_imc_counters_stop (OPAL_IMC_COUNTERS_NEST ,get_hard_smp_processor_id (cpu)); }
Signature · 1 line
2.15.1
PATCH 186/189 perf test: Fix test trace+probe_libc_inet_pton.sh for s390x
In reply to Sasha LevinFrom: Thomas Richter <[email protected]>
[ Upstream commit 7a92453620d42c3a5fea94a864dc6aa04c262b93 ]
On Intel test case trace+probe_libc_inet_pton.sh succeeds and the output is:
[root@f27 perf]# ./perf trace --no-syscalls
-e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.037 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.037/0.037/0.037/0.000 ms
0.000 probe_libc:inet_pton:(7fa40ac618a0))
__GI___inet_pton (/usr/lib64/libc-2.26.so)
getaddrinfo (/usr/lib64/libc-2.26.so)
main (/usr/bin/ping)The kernel stack unwinder is used, it is specified implicitly as call-graph=fp (frame pointer).
On s390x only dwarf is available for stack unwinding. It is also done in user space. This requires different parameter setup and result checking for s390x and Intel.
This patch adds separate perf trace setup and result checking for Intel and s390x. On s390x specify this command line to get a call-graph and handle the different call graph result checking:
[root@s35lp76 perf]# ./perf trace --no-syscalls
-e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.041 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.041/0.041/0.041/0.000 ms
0.000 probe_libc:inet_pton:(3ffb9942060))
__GI___inet_pton (/usr/lib64/libc-2.26.so)
gaih_inet (inlined)
__GI_getaddrinfo (inlined)
main (/usr/bin/ping)
__libc_start_main (/usr/lib64/libc-2.26.so)
_start (/usr/bin/ping)[root@s35lp76 perf]#
Before:
[root@s8360047 perf]# ./perf test -vv 58
58: probe libc's inet_pton & backtrace it with ping :
--- start ---
test child forked, pid 26349
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.079 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.079/0.079/0.079/0.000 ms 0.000 probe_libc:inet_pton:(3ff925c2060))
test child finished with -1
---- end ----
probe libc's inet_pton & backtrace it with ping: FAILED! [root@s8360047 perf]#
After:
[root@s35lp76 perf]# ./perf test -vv 57
57: probe libc's inet_pton & backtrace it with ping :
--- start ---
test child forked, pid 38708
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.038 ms
--- ::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.038/0.038/0.038/0.000 ms 0.000 probe_libc:inet_pton:(3ff87342060)) __GI___inet_pton (/usr/lib64/libc-2.26.so) gaih_inet (inlined)__GI_getaddrinfo (inlined)
main (/usr/bin/ping)__libc_start_main (/usr/lib64/libc-2.26.so)_start (/usr/bin/ping)
test child finished with 0
---- end ----
probe libc's inet_pton & backtrace it with ping: Ok [root@s35lp76 perf]#
On Intel the test case runs unchanged and succeeds.
--- .../perf/tests/shell/trace+probe_libc_inet_pton.sh | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
tools/perf/tests/shell/trace+probe_libc_inet_pton.sh +18 -5
@@ -22,10 +22,23 @@ trace_libc_inet_pton_backtrace() { expected[4]="rtt min.*" expected[5]="[0-9]+\.[0-9]+[[:space:]]+probe_libc:inet_pton:\([[:xdigit:]]+\)" expected[6]=".*inet_pton[[:space:]]\($libc\)$" - expected[7]="getaddrinfo[[:space:]]\($libc\)$" - expected[8]=".*\(.*/bin/ping.*\)$" - - perf trace --no-syscalls -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do + case "$(uname -m)" in + s390x) + eventattr='call-graph=dwarf' + expected[7]="gaih_inet[[:space:]]\(inlined\)$" + expected[8]="__GI_getaddrinfo[[:space:]]\(inlined\)$" + expected[9]="main[[:space:]]\(.*/bin/ping.*\)$" + expected[10]="__libc_start_main[[:space:]]\($libc\)$" + expected[11]="_start[[:space:]]\(.*/bin/ping.*\)$" + ;; + *) + eventattr='max-stack=3' + expected[7]="getaddrinfo[[:space:]]\($libc\)$" + expected[8]=".*\(.*/bin/ping.*\)$" + ;; + esac + + perf trace --no-syscalls -e probe_libc:inet_pton/$eventattr/ ping -6 -c 1 ::1 2>&1 | grep -v ^$ | while read line ; do echo $line echo "$line" | egrep -q "${expected[$idx]}" if [ $? -ne 0 ] ; then
@@ -33,7 +46,7 @@ trace_libc_inet_pton_backtrace() { exit 1 fi let idx+=1 - [ $idx -eq 9 ] && break + [ -z "${expected[$idx]}" ] && break done }
Signature · 1 line
2.15.1
PATCH 187/189 irqchip/gic-v3: Ignore disabled ITS nodes
In reply to Sasha LevinFrom: Stephen Boyd <[email protected]>
[ Upstream commit 95a2562590c2f64a0398183f978d5cf3db6d0284 ]
On some platforms there's an ITS available but it's not enabled because reading or writing the registers is denied by the firmware. In fact, reading or writing them will cause the system to reset. We could remove the node from DT in such a case, but it's better to skip nodes that are marked as "disabled" in DT so that we can describe the hardware that exists and use the status property to indicate how the firmware has configured things.
--- drivers/irqchip/irq-gic-v3-its-pci-msi.c | 2 ++ drivers/irqchip/irq-gic-v3-its-platform-msi.c | 2 ++ drivers/irqchip/irq-gic-v3-its.c | 2 ++ drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c | 2 ++ 4 files changed, 8 insertions(+)
drivers/irqchip/irq-gic-v3-its-pci-msi.c +2 -0
@@ -132,6 +132,8 @@ static int __init its_pci_of_msi_init(void)for (np =of_find_matching_node (NULL , its_device_id); np; np =of_find_matching_node (np, its_device_id)) { +if (!of_device_is_available (np)) +continue ;if (!of_property_read_bool (np,"msi-controller" ))continue ;
drivers/irqchip/irq-gic-v3-its-platform-msi.c +2 -0
@@ -154,6 +154,8 @@ static void __init its_pmsi_of_init(void)for (np =of_find_matching_node (NULL , its_device_id); np; np =of_find_matching_node (np, its_device_id)) { +if (!of_device_is_available (np)) +continue ;if (!of_property_read_bool (np,"msi-controller" ))continue ;
drivers/irqchip/irq-gic-v3-its.c +2 -0
@@ -3313,6 +3313,8 @@ static int __init its_of_probe(struct device_node *node)for (np =of_find_matching_node (node, its_device_id); np; np =of_find_matching_node (np, its_device_id)) { +if (!of_device_is_available (np)) +continue ;if (!of_property_read_bool (np,"msi-controller" )) {pr_warn ("%pOF: no msi-controller property, ITS ignored\n" , np);
drivers/staging/fsl-mc/bus/irq-gic-v3-its-fsl-mc-msi.c +2 -0
@@ -75,6 +75,8 @@ int __init its_fsl_mc_msi_init(void)for (np =of_find_matching_node (NULL , its_device_id); np; np =of_find_matching_node (np, its_device_id)) { +if (!of_device_is_available (np)) +continue ;if (!of_property_read_bool (np,"msi-controller" ))continue ;
Signature · 1 line
2.15.1
PATCH 188/189 cpumask: Make for_each_cpu_wrap() available on UP as well
In reply to Sasha LevinFrom: Michael Kelley <[email protected]>
[ Upstream commit d207af2eab3f8668b95ad02b21930481c42806fd ]
for_each_cpu_wrap() was originally added in the #else half of a large "#if NR_CPUS == 1" statement, but was omitted in the #if half. This patch adds the missing #if half to prevent compile errors when NR_CPUS is 1.
--- include/linux/cpumask.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/cpumask.h +2 -0
@@ -170,6 +170,8 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)#define for_each_cpu_not (cpu, mask) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) +#define for_each_cpu_wrap (cpu, mask, start) \ + for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)(start))#define for_each_cpu_and (cpu, mask, and) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)#else
Signature · 1 line
2.15.1
PATCH 189/189 irqchip/gic-v3: Change pr_debug message to pr_devel
In reply to Sasha LevinFrom: Mark Salter <[email protected]>
[ Upstream commit b6dd4d83dc2f78cebc9a7e6e7e4bc2be4d29b94d ]
The pr_debug() in gic-v3 gic_send_sgi() can trigger a circular locking warning:
GICv3: CPU10: ICC_SGI1R_EL1 5000400
======================================================
WARNING: possible circular locking dependency detected
4.15.0+ #1 Tainted: G W
------------------------------------------------------
dynamic_debug01/1873 is trying to acquire lock:
((console_sem).lock){-...}, at: [<0000000099c891ec>] down_trylock+0x20/0x4c
but task is already holding lock:
(&rq->lock){-.-.}, at: [<00000000842e1587>] __task_rq_lock+0x54/0xdc
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&rq->lock){-.-.}:
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock+0x4c/0x60
task_fork_fair+0x3c/0x148
sched_fork+0x10c/0x214
copy_process.isra.32.part.33+0x4e8/0x14f0
_do_fork+0xe8/0x78c
kernel_thread+0x48/0x54
rest_init+0x34/0x2a4
start_kernel+0x45c/0x488-> #1 (&p->pi_lock){-.-.}:
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock_irqsave+0x58/0x70
try_to_wake_up+0x48/0x600
wake_up_process+0x28/0x34
__up.isra.0+0x60/0x6c
up+0x60/0x68
__up_console_sem+0x4c/0x7c
console_unlock+0x328/0x634
vprintk_emit+0x25c/0x390
dev_vprintk_emit+0xc4/0x1fc
dev_printk_emit+0x88/0xa8
__dev_printk+0x58/0x9c
_dev_info+0x84/0xa8
usb_new_device+0x100/0x474
hub_port_connect+0x280/0x92c
hub_event+0x740/0xa84
process_one_work+0x240/0x70c
worker_thread+0x60/0x400
kthread+0x110/0x13c
ret_from_fork+0x10/0x18-> #0 ((console_sem).lock){-...}:
validate_chain.isra.34+0x6e4/0xa20
__lock_acquire+0x3b4/0x6e0
lock_acquire+0xf4/0x2a8
_raw_spin_lock_irqsave+0x58/0x70
down_trylock+0x20/0x4c
__down_trylock_console_sem+0x3c/0x9c
console_trylock+0x20/0xb0
vprintk_emit+0x254/0x390
vprintk_default+0x58/0x90
vprintk_func+0xbc/0x164
printk+0x80/0xa0
__dynamic_pr_debug+0x84/0xac
gic_raise_softirq+0x184/0x18c
smp_cross_call+0xac/0x218
smp_send_reschedule+0x3c/0x48
resched_curr+0x60/0x9c
check_preempt_curr+0x70/0xdc
wake_up_new_task+0x310/0x470
_do_fork+0x188/0x78c
SyS_clone+0x44/0x50
__sys_trace_return+0x0/0x4other info that might help us debug this:
Chain exists of: (console_sem).lock --> &p->pi_lock --> &rq->lock Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&rq->lock);
lock(&p->pi_lock);
lock(&rq->lock);lock((console_sem).lock);
*** DEADLOCK ***
2 locks held by dynamic_debug01/1873:
#0: (&p->pi_lock){-.-.}, at: [<000000001366df53>] wake_up_new_task+0x40/0x470 #1: (&rq->lock){-.-.}, at: [<00000000842e1587>] __task_rq_lock+0x54/0xdc
stack backtrace: CPU: 10 PID: 1873 Comm: dynamic_debug01 Tainted: G W 4.15.0+ #1 Hardware name: GIGABYTE R120-T34-00/MT30-GS2-00, BIOS T48 10/02/2017 Call trace: dump_backtrace+0x0/0x188 show_stack+0x24/0x2c dump_stack+0xa4/0xe0 print_circular_bug.isra.31+0x29c/0x2b8 check_prev_add.constprop.39+0x6c8/0x6dc validate_chain.isra.34+0x6e4/0xa20 __lock_acquire+0x3b4/0x6e0 lock_acquire+0xf4/0x2a8 _raw_spin_lock_irqsave+0x58/0x70 down_trylock+0x20/0x4c __down_trylock_console_sem+0x3c/0x9c console_trylock+0x20/0xb0 vprintk_emit+0x254/0x390 vprintk_default+0x58/0x90 vprintk_func+0xbc/0x164 printk+0x80/0xa0 __dynamic_pr_debug+0x84/0xac gic_raise_softirq+0x184/0x18c smp_cross_call+0xac/0x218 smp_send_reschedule+0x3c/0x48 resched_curr+0x60/0x9c check_preempt_curr+0x70/0xdc wake_up_new_task+0x310/0x470 _do_fork+0x188/0x78c SyS_clone+0x44/0x50 __sys_trace_return+0x0/0x4 GICv3: CPU0: ICC_SGI1R_EL1 12000
This could be fixed with printk_deferred() but that might lessen its usefulness for debugging. So change it to pr_devel to keep it out of production kernels. Developers working on gic-v3 can enable it as needed in their kernels.
--- drivers/irqchip/irq-gic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -673,7 +673,7 @@ static void gic_send_sgi(u64 cluster_id, u16 tlist, unsigned int irq)MPIDR_TO_SGI_RS (cluster_id) | tlist << ICC_SGI1R_TARGET_LIST_SHIFT); -pr_debug ("CPU%d: ICC_SGI1R_EL1 %llx\n" ,smp_processor_id (), val); +pr_devel ("CPU%d: ICC_SGI1R_EL1 %llx\n" ,smp_processor_id (), val);gic_write_sgi1r (val); }
Signature · 1 line
2.15.1