Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
"14 fixes and one selftest to verify the ipc fixes herein"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm: limit boost_watermark on small zones
ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST
mm/vmscan: remove unnecessary argument description of isolate_lru_pages()
epoll: atomically remove wait entry on wake up
kselftests: introduce new epoll60 testcase for catching lost wakeups
percpu: make pcpu_alloc() aware of current gfp context
mm/slub: fix incorrect interpretation of s->offset
scripts/gdb: repair rb_first() and rb_last()
eventpoll: fix missing wakeup for ovflist in ep_poll_callback
arch/x86/kvm/svm/sev.c: change flag passed to GUP fast in sev_pin_memory()
scripts/decodecode: fix trapping instruction formatting
kernel/kcov.c: fix typos in kcov_remote_start documentation
mm/page_alloc: fix watchdog soft lockups during set_zone_contiguous()
mm, memcg: fix error return value of mem_cgroup_css_alloc()
ipc/mqueue.c: change __do_notify() to bypass check_kill_permission()

+276 -79
+1 -1
arch/x86/kvm/svm/sev.c
··· 345 345 return NULL; 346 346 347 347 /* Pin the user virtual address. */ 348 - npinned = get_user_pages_fast(uaddr, npages, FOLL_WRITE, pages); 348 + npinned = get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, pages); 349 349 if (npinned != npages) { 350 350 pr_err("SEV: Failure locking %lu pages.\n", npages); 351 351 goto err;
+33 -28
fs/eventpoll.c
··· 1171 1171 { 1172 1172 struct eventpoll *ep = epi->ep; 1173 1173 1174 + /* Fast preliminary check */ 1175 + if (epi->next != EP_UNACTIVE_PTR) 1176 + return false; 1177 + 1174 1178 /* Check that the same epi has not been just chained from another CPU */ 1175 1179 if (cmpxchg(&epi->next, EP_UNACTIVE_PTR, NULL) != EP_UNACTIVE_PTR) 1176 1180 return false; ··· 1241 1237 * chained in ep->ovflist and requeued later on. 1242 1238 */ 1243 1239 if (READ_ONCE(ep->ovflist) != EP_UNACTIVE_PTR) { 1244 - if (epi->next == EP_UNACTIVE_PTR && 1245 - chain_epi_lockless(epi)) 1240 + if (chain_epi_lockless(epi)) 1246 1241 ep_pm_stay_awake_rcu(epi); 1247 - goto out_unlock; 1248 - } 1249 - 1250 - /* If this file is already in the ready list we exit soon */ 1251 - if (!ep_is_linked(epi) && 1252 - list_add_tail_lockless(&epi->rdllink, &ep->rdllist)) { 1253 - ep_pm_stay_awake_rcu(epi); 1242 + } else if (!ep_is_linked(epi)) { 1243 + /* In the usual case, add event to ready list. */ 1244 + if (list_add_tail_lockless(&epi->rdllink, &ep->rdllist)) 1245 + ep_pm_stay_awake_rcu(epi); 1254 1246 } 1255 1247 1256 1248 /* ··· 1822 1822 { 1823 1823 int res = 0, eavail, timed_out = 0; 1824 1824 u64 slack = 0; 1825 - bool waiter = false; 1826 1825 wait_queue_entry_t wait; 1827 1826 ktime_t expires, *to = NULL; 1828 1827 ··· 1866 1867 */ 1867 1868 ep_reset_busy_poll_napi_id(ep); 1868 1869 1869 - /* 1870 - * We don't have any available event to return to the caller. We need 1871 - * to sleep here, and we will be woken by ep_poll_callback() when events 1872 - * become available. 1873 - */ 1874 - if (!waiter) { 1875 - waiter = true; 1876 - init_waitqueue_entry(&wait, current); 1877 - 1870 + do { 1871 + /* 1872 + * Internally init_wait() uses autoremove_wake_function(), 1873 + * thus wait entry is removed from the wait queue on each 1874 + * wakeup. Why it is important? In case of several waiters 1875 + * each new wakeup will hit the next waiter, giving it the 1876 + * chance to harvest new event. Otherwise wakeup can be 1877 + * lost. This is also good performance-wise, because on 1878 + * normal wakeup path no need to call __remove_wait_queue() 1879 + * explicitly, thus ep->lock is not taken, which halts the 1880 + * event delivery. 1881 + */ 1882 + init_wait(&wait); 1878 1883 write_lock_irq(&ep->lock); 1879 1884 __add_wait_queue_exclusive(&ep->wq, &wait); 1880 1885 write_unlock_irq(&ep->lock); 1881 - } 1882 1886 1883 - for (;;) { 1884 1887 /* 1885 1888 * We don't want to sleep if the ep_poll_callback() sends us 1886 1889 * a wakeup in between. That's why we set the task state ··· 1912 1911 timed_out = 1; 1913 1912 break; 1914 1913 } 1915 - } 1914 + 1915 + /* We were woken up, thus go and try to harvest some events */ 1916 + eavail = 1; 1917 + 1918 + } while (0); 1916 1919 1917 1920 __set_current_state(TASK_RUNNING); 1921 + 1922 + if (!list_empty_careful(&wait.entry)) { 1923 + write_lock_irq(&ep->lock); 1924 + __remove_wait_queue(&ep->wq, &wait); 1925 + write_unlock_irq(&ep->lock); 1926 + } 1918 1927 1919 1928 send_events: 1920 1929 /* ··· 1935 1924 if (!res && eavail && 1936 1925 !(res = ep_send_events(ep, events, maxevents)) && !timed_out) 1937 1926 goto fetch_events; 1938 - 1939 - if (waiter) { 1940 - write_lock_irq(&ep->lock); 1941 - __remove_wait_queue(&ep->wq, &wait); 1942 - write_unlock_irq(&ep->lock); 1943 - } 1944 1927 1945 1928 return res; 1946 1929 }
+26 -8
ipc/mqueue.c
··· 142 142 143 143 struct sigevent notify; 144 144 struct pid *notify_owner; 145 + u32 notify_self_exec_id; 145 146 struct user_namespace *notify_user_ns; 146 147 struct user_struct *user; /* user who created, for accounting */ 147 148 struct sock *notify_sock; ··· 774 773 * synchronously. */ 775 774 if (info->notify_owner && 776 775 info->attr.mq_curmsgs == 1) { 777 - struct kernel_siginfo sig_i; 778 776 switch (info->notify.sigev_notify) { 779 777 case SIGEV_NONE: 780 778 break; 781 - case SIGEV_SIGNAL: 782 - /* sends signal */ 779 + case SIGEV_SIGNAL: { 780 + struct kernel_siginfo sig_i; 781 + struct task_struct *task; 782 + 783 + /* do_mq_notify() accepts sigev_signo == 0, why?? */ 784 + if (!info->notify.sigev_signo) 785 + break; 783 786 784 787 clear_siginfo(&sig_i); 785 788 sig_i.si_signo = info->notify.sigev_signo; 786 789 sig_i.si_errno = 0; 787 790 sig_i.si_code = SI_MESGQ; 788 791 sig_i.si_value = info->notify.sigev_value; 789 - /* map current pid/uid into info->owner's namespaces */ 790 792 rcu_read_lock(); 793 + /* map current pid/uid into info->owner's namespaces */ 791 794 sig_i.si_pid = task_tgid_nr_ns(current, 792 795 ns_of_pid(info->notify_owner)); 793 - sig_i.si_uid = from_kuid_munged(info->notify_user_ns, current_uid()); 796 + sig_i.si_uid = from_kuid_munged(info->notify_user_ns, 797 + current_uid()); 798 + /* 799 + * We can't use kill_pid_info(), this signal should 800 + * bypass check_kill_permission(). It is from kernel 801 + * but si_fromuser() can't know this. 802 + * We do check the self_exec_id, to avoid sending 803 + * signals to programs that don't expect them. 804 + */ 805 + task = pid_task(info->notify_owner, PIDTYPE_TGID); 806 + if (task && task->self_exec_id == 807 + info->notify_self_exec_id) { 808 + do_send_sig_info(info->notify.sigev_signo, 809 + &sig_i, task, PIDTYPE_TGID); 810 + } 794 811 rcu_read_unlock(); 795 - 796 - kill_pid_info(info->notify.sigev_signo, 797 - &sig_i, info->notify_owner); 798 812 break; 813 + } 799 814 case SIGEV_THREAD: 800 815 set_cookie(info->notify_cookie, NOTIFY_WOKENUP); 801 816 netlink_sendskb(info->notify_sock, info->notify_cookie); ··· 1400 1383 info->notify.sigev_signo = notification->sigev_signo; 1401 1384 info->notify.sigev_value = notification->sigev_value; 1402 1385 info->notify.sigev_notify = SIGEV_SIGNAL; 1386 + info->notify_self_exec_id = current->self_exec_id; 1403 1387 break; 1404 1388 } 1405 1389
+2 -2
kernel/kcov.c
··· 740 740 * kcov_remote_handle() with KCOV_SUBSYSTEM_COMMON as the subsystem id and an 741 741 * arbitrary 4-byte non-zero number as the instance id). This common handle 742 742 * then gets saved into the task_struct of the process that issued the 743 - * KCOV_REMOTE_ENABLE ioctl. When this proccess issues system calls that spawn 744 - * kernel threads, the common handle must be retrived via kcov_common_handle() 743 + * KCOV_REMOTE_ENABLE ioctl. When this process issues system calls that spawn 744 + * kernel threads, the common handle must be retrieved via kcov_common_handle() 745 745 * and passed to the spawned threads via custom annotations. Those kernel 746 746 * threads must in turn be annotated with kcov_remote_start(common_handle) and 747 747 * kcov_remote_stop(). All of the threads that are spawned by the same process
+7 -10
lib/Kconfig.ubsan
··· 60 60 Enabling this option will get kernel image size increased 61 61 significantly. 62 62 63 - config UBSAN_NO_ALIGNMENT 64 - bool "Disable checking of pointers alignment" 65 - default y if HAVE_EFFICIENT_UNALIGNED_ACCESS 66 - help 67 - This option disables the check of unaligned memory accesses. 68 - This option should be used when building allmodconfig. 69 - Disabling this option on architectures that support unaligned 70 - accesses may produce a lot of false positives. 71 - 72 63 config UBSAN_ALIGNMENT 73 - def_bool !UBSAN_NO_ALIGNMENT 64 + bool "Enable checks for pointers alignment" 65 + default !HAVE_EFFICIENT_UNALIGNED_ACCESS 66 + depends on !X86 || !COMPILE_TEST 67 + help 68 + This option enables the check of unaligned memory accesses. 69 + Enabling this option on architectures that support unaligned 70 + accesses may produce a lot of false positives. 74 71 75 72 config TEST_UBSAN 76 73 tristate "Module for testing for undefined behavior detection"
+9 -6
mm/memcontrol.c
··· 4990 4990 unsigned int size; 4991 4991 int node; 4992 4992 int __maybe_unused i; 4993 + long error = -ENOMEM; 4993 4994 4994 4995 size = sizeof(struct mem_cgroup); 4995 4996 size += nr_node_ids * sizeof(struct mem_cgroup_per_node *); 4996 4997 4997 4998 memcg = kzalloc(size, GFP_KERNEL); 4998 4999 if (!memcg) 4999 - return NULL; 5000 + return ERR_PTR(error); 5000 5001 5001 5002 memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL, 5002 5003 1, MEM_CGROUP_ID_MAX, 5003 5004 GFP_KERNEL); 5004 - if (memcg->id.id < 0) 5005 + if (memcg->id.id < 0) { 5006 + error = memcg->id.id; 5005 5007 goto fail; 5008 + } 5006 5009 5007 5010 memcg->vmstats_local = alloc_percpu(struct memcg_vmstats_percpu); 5008 5011 if (!memcg->vmstats_local) ··· 5049 5046 fail: 5050 5047 mem_cgroup_id_remove(memcg); 5051 5048 __mem_cgroup_free(memcg); 5052 - return NULL; 5049 + return ERR_PTR(error); 5053 5050 } 5054 5051 5055 5052 static struct cgroup_subsys_state * __ref ··· 5060 5057 long error = -ENOMEM; 5061 5058 5062 5059 memcg = mem_cgroup_alloc(); 5063 - if (!memcg) 5064 - return ERR_PTR(error); 5060 + if (IS_ERR(memcg)) 5061 + return ERR_CAST(memcg); 5065 5062 5066 5063 WRITE_ONCE(memcg->high, PAGE_COUNTER_MAX); 5067 5064 memcg->soft_limit = PAGE_COUNTER_MAX; ··· 5111 5108 fail: 5112 5109 mem_cgroup_id_remove(memcg); 5113 5110 mem_cgroup_free(memcg); 5114 - return ERR_PTR(-ENOMEM); 5111 + return ERR_PTR(error); 5115 5112 } 5116 5113 5117 5114 static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
+9
mm/page_alloc.c
··· 1607 1607 if (!__pageblock_pfn_to_page(block_start_pfn, 1608 1608 block_end_pfn, zone)) 1609 1609 return; 1610 + cond_resched(); 1610 1611 } 1611 1612 1612 1613 /* We confirm that there is no hole */ ··· 2400 2399 unsigned long max_boost; 2401 2400 2402 2401 if (!watermark_boost_factor) 2402 + return; 2403 + /* 2404 + * Don't bother in zones that are unlikely to produce results. 2405 + * On small machines, including kdump capture kernels running 2406 + * in a small area, boosting the watermark can cause an out of 2407 + * memory situation immediately. 2408 + */ 2409 + if ((pageblock_nr_pages * 4) > zone_managed_pages(zone)) 2403 2410 return; 2404 2411 2405 2412 max_boost = mult_frac(zone->_watermark[WMARK_HIGH],
+10 -4
mm/percpu.c
··· 80 80 #include <linux/workqueue.h> 81 81 #include <linux/kmemleak.h> 82 82 #include <linux/sched.h> 83 + #include <linux/sched/mm.h> 83 84 84 85 #include <asm/cacheflush.h> 85 86 #include <asm/sections.h> ··· 1558 1557 static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, 1559 1558 gfp_t gfp) 1560 1559 { 1561 - /* whitelisted flags that can be passed to the backing allocators */ 1562 - gfp_t pcpu_gfp = gfp & (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); 1563 - bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL; 1564 - bool do_warn = !(gfp & __GFP_NOWARN); 1560 + gfp_t pcpu_gfp; 1561 + bool is_atomic; 1562 + bool do_warn; 1565 1563 static int warn_limit = 10; 1566 1564 struct pcpu_chunk *chunk, *next; 1567 1565 const char *err; ··· 1568 1568 unsigned long flags; 1569 1569 void __percpu *ptr; 1570 1570 size_t bits, bit_align; 1571 + 1572 + gfp = current_gfp_context(gfp); 1573 + /* whitelisted flags that can be passed to the backing allocators */ 1574 + pcpu_gfp = gfp & (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); 1575 + is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL; 1576 + do_warn = !(gfp & __GFP_NOWARN); 1571 1577 1572 1578 /* 1573 1579 * There is now a minimum allocation size of PCPU_MIN_ALLOC_SIZE,
+30 -15
mm/slub.c
··· 551 551 metadata_access_disable(); 552 552 } 553 553 554 + /* 555 + * See comment in calculate_sizes(). 556 + */ 557 + static inline bool freeptr_outside_object(struct kmem_cache *s) 558 + { 559 + return s->offset >= s->inuse; 560 + } 561 + 562 + /* 563 + * Return offset of the end of info block which is inuse + free pointer if 564 + * not overlapping with object. 565 + */ 566 + static inline unsigned int get_info_end(struct kmem_cache *s) 567 + { 568 + if (freeptr_outside_object(s)) 569 + return s->inuse + sizeof(void *); 570 + else 571 + return s->inuse; 572 + } 573 + 554 574 static struct track *get_track(struct kmem_cache *s, void *object, 555 575 enum track_item alloc) 556 576 { 557 577 struct track *p; 558 578 559 - if (s->offset) 560 - p = object + s->offset + sizeof(void *); 561 - else 562 - p = object + s->inuse; 579 + p = object + get_info_end(s); 563 580 564 581 return p + alloc; 565 582 } ··· 703 686 print_section(KERN_ERR, "Redzone ", p + s->object_size, 704 687 s->inuse - s->object_size); 705 688 706 - if (s->offset) 707 - off = s->offset + sizeof(void *); 708 - else 709 - off = s->inuse; 689 + off = get_info_end(s); 710 690 711 691 if (s->flags & SLAB_STORE_USER) 712 692 off += 2 * sizeof(struct track); ··· 796 782 * object address 797 783 * Bytes of the object to be managed. 798 784 * If the freepointer may overlay the object then the free 799 - * pointer is the first word of the object. 785 + * pointer is at the middle of the object. 800 786 * 801 787 * Poisoning uses 0x6b (POISON_FREE) and the last byte is 802 788 * 0xa5 (POISON_END) ··· 830 816 831 817 static int check_pad_bytes(struct kmem_cache *s, struct page *page, u8 *p) 832 818 { 833 - unsigned long off = s->inuse; /* The end of info */ 834 - 835 - if (s->offset) 836 - /* Freepointer is placed after the object. */ 837 - off += sizeof(void *); 819 + unsigned long off = get_info_end(s); /* The end of info */ 838 820 839 821 if (s->flags & SLAB_STORE_USER) 840 822 /* We also have user information there */ ··· 917 907 check_pad_bytes(s, page, p); 918 908 } 919 909 920 - if (!s->offset && val == SLUB_RED_ACTIVE) 910 + if (!freeptr_outside_object(s) && val == SLUB_RED_ACTIVE) 921 911 /* 922 912 * Object and freepointer overlap. Cannot check 923 913 * freepointer while object is allocated. ··· 3597 3587 * 3598 3588 * This is the case if we do RCU, have a constructor or 3599 3589 * destructor or are poisoning the objects. 3590 + * 3591 + * The assumption that s->offset >= s->inuse means free 3592 + * pointer is outside of the object is used in the 3593 + * freeptr_outside_object() function. If that is no 3594 + * longer true, the function needs to be modified. 3600 3595 */ 3601 3596 s->offset = size; 3602 3597 size += sizeof(void *);
-1
mm/vmscan.c
··· 1625 1625 * @dst: The temp list to put pages on to. 1626 1626 * @nr_scanned: The number of pages that were scanned. 1627 1627 * @sc: The scan_control struct for this reclaim session 1628 - * @mode: One of the LRU isolation modes 1629 1628 * @lru: LRU list id for isolating 1630 1629 * 1631 1630 * returns how many pages were moved onto *@dst.
+1 -1
scripts/decodecode
··· 126 126 faultline=`cat $T.dis | head -1 | cut -d":" -f2-` 127 127 faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'` 128 128 129 - cat $T.oo | sed -e "${faultlinenum}s/^\(.*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/" 129 + cat $T.oo | sed -e "${faultlinenum}s/^\([^:]*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/" 130 130 echo 131 131 cat $T.aa 132 132 cleanup
+2 -2
scripts/gdb/linux/rbtree.py
··· 12 12 13 13 def rb_first(root): 14 14 if root.type == rb_root_type.get_type(): 15 - node = node.address.cast(rb_root_type.get_type().pointer()) 15 + node = root.address.cast(rb_root_type.get_type().pointer()) 16 16 elif root.type != rb_root_type.get_type().pointer(): 17 17 raise gdb.GdbError("Must be struct rb_root not {}".format(root.type)) 18 18 ··· 28 28 29 29 def rb_last(root): 30 30 if root.type == rb_root_type.get_type(): 31 - node = node.address.cast(rb_root_type.get_type().pointer()) 31 + node = root.address.cast(rb_root_type.get_type().pointer()) 32 32 elif root.type != rb_root_type.get_type().pointer(): 33 33 raise gdb.GdbError("Must be struct rb_root not {}".format(root.type)) 34 34
+146
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
··· 3 3 #define _GNU_SOURCE 4 4 #include <poll.h> 5 5 #include <unistd.h> 6 + #include <assert.h> 6 7 #include <signal.h> 7 8 #include <pthread.h> 8 9 #include <sys/epoll.h> ··· 3135 3134 } 3136 3135 close(ctx.efd[0]); 3137 3136 close(ctx.sfd[0]); 3137 + } 3138 + 3139 + enum { 3140 + EPOLL60_EVENTS_NR = 10, 3141 + }; 3142 + 3143 + struct epoll60_ctx { 3144 + volatile int stopped; 3145 + int ready; 3146 + int waiters; 3147 + int epfd; 3148 + int evfd[EPOLL60_EVENTS_NR]; 3149 + }; 3150 + 3151 + static void *epoll60_wait_thread(void *ctx_) 3152 + { 3153 + struct epoll60_ctx *ctx = ctx_; 3154 + struct epoll_event e; 3155 + sigset_t sigmask; 3156 + uint64_t v; 3157 + int ret; 3158 + 3159 + /* Block SIGUSR1 */ 3160 + sigemptyset(&sigmask); 3161 + sigaddset(&sigmask, SIGUSR1); 3162 + sigprocmask(SIG_SETMASK, &sigmask, NULL); 3163 + 3164 + /* Prepare empty mask for epoll_pwait() */ 3165 + sigemptyset(&sigmask); 3166 + 3167 + while (!ctx->stopped) { 3168 + /* Mark we are ready */ 3169 + __atomic_fetch_add(&ctx->ready, 1, __ATOMIC_ACQUIRE); 3170 + 3171 + /* Start when all are ready */ 3172 + while (__atomic_load_n(&ctx->ready, __ATOMIC_ACQUIRE) && 3173 + !ctx->stopped); 3174 + 3175 + /* Account this waiter */ 3176 + __atomic_fetch_add(&ctx->waiters, 1, __ATOMIC_ACQUIRE); 3177 + 3178 + ret = epoll_pwait(ctx->epfd, &e, 1, 2000, &sigmask); 3179 + if (ret != 1) { 3180 + /* We expect only signal delivery on stop */ 3181 + assert(ret < 0 && errno == EINTR && "Lost wakeup!\n"); 3182 + assert(ctx->stopped); 3183 + break; 3184 + } 3185 + 3186 + ret = read(e.data.fd, &v, sizeof(v)); 3187 + /* Since we are on ET mode, thus each thread gets its own fd. */ 3188 + assert(ret == sizeof(v)); 3189 + 3190 + __atomic_fetch_sub(&ctx->waiters, 1, __ATOMIC_RELEASE); 3191 + } 3192 + 3193 + return NULL; 3194 + } 3195 + 3196 + static inline unsigned long long msecs(void) 3197 + { 3198 + struct timespec ts; 3199 + unsigned long long msecs; 3200 + 3201 + clock_gettime(CLOCK_REALTIME, &ts); 3202 + msecs = ts.tv_sec * 1000ull; 3203 + msecs += ts.tv_nsec / 1000000ull; 3204 + 3205 + return msecs; 3206 + } 3207 + 3208 + static inline int count_waiters(struct epoll60_ctx *ctx) 3209 + { 3210 + return __atomic_load_n(&ctx->waiters, __ATOMIC_ACQUIRE); 3211 + } 3212 + 3213 + TEST(epoll60) 3214 + { 3215 + struct epoll60_ctx ctx = { 0 }; 3216 + pthread_t waiters[ARRAY_SIZE(ctx.evfd)]; 3217 + struct epoll_event e; 3218 + int i, n, ret; 3219 + 3220 + signal(SIGUSR1, signal_handler); 3221 + 3222 + ctx.epfd = epoll_create1(0); 3223 + ASSERT_GE(ctx.epfd, 0); 3224 + 3225 + /* Create event fds */ 3226 + for (i = 0; i < ARRAY_SIZE(ctx.evfd); i++) { 3227 + ctx.evfd[i] = eventfd(0, EFD_NONBLOCK); 3228 + ASSERT_GE(ctx.evfd[i], 0); 3229 + 3230 + e.events = EPOLLIN | EPOLLET; 3231 + e.data.fd = ctx.evfd[i]; 3232 + ASSERT_EQ(epoll_ctl(ctx.epfd, EPOLL_CTL_ADD, ctx.evfd[i], &e), 0); 3233 + } 3234 + 3235 + /* Create waiter threads */ 3236 + for (i = 0; i < ARRAY_SIZE(waiters); i++) 3237 + ASSERT_EQ(pthread_create(&waiters[i], NULL, 3238 + epoll60_wait_thread, &ctx), 0); 3239 + 3240 + for (i = 0; i < 300; i++) { 3241 + uint64_t v = 1, ms; 3242 + 3243 + /* Wait for all to be ready */ 3244 + while (__atomic_load_n(&ctx.ready, __ATOMIC_ACQUIRE) != 3245 + ARRAY_SIZE(ctx.evfd)) 3246 + ; 3247 + 3248 + /* Steady, go */ 3249 + __atomic_fetch_sub(&ctx.ready, ARRAY_SIZE(ctx.evfd), 3250 + __ATOMIC_ACQUIRE); 3251 + 3252 + /* Wait all have gone to kernel */ 3253 + while (count_waiters(&ctx) != ARRAY_SIZE(ctx.evfd)) 3254 + ; 3255 + 3256 + /* 1ms should be enough to schedule away */ 3257 + usleep(1000); 3258 + 3259 + /* Quickly signal all handles at once */ 3260 + for (n = 0; n < ARRAY_SIZE(ctx.evfd); n++) { 3261 + ret = write(ctx.evfd[n], &v, sizeof(v)); 3262 + ASSERT_EQ(ret, sizeof(v)); 3263 + } 3264 + 3265 + /* Busy loop for 1s and wait for all waiters to wake up */ 3266 + ms = msecs(); 3267 + while (count_waiters(&ctx) && msecs() < ms + 1000) 3268 + ; 3269 + 3270 + ASSERT_EQ(count_waiters(&ctx), 0); 3271 + } 3272 + ctx.stopped = 1; 3273 + /* Stop waiters */ 3274 + for (i = 0; i < ARRAY_SIZE(waiters); i++) 3275 + ret = pthread_kill(waiters[i], SIGUSR1); 3276 + for (i = 0; i < ARRAY_SIZE(waiters); i++) 3277 + pthread_join(waiters[i], NULL); 3278 + 3279 + for (i = 0; i < ARRAY_SIZE(waiters); i++) 3280 + close(ctx.evfd[i]); 3281 + close(ctx.epfd); 3138 3282 } 3139 3283 3140 3284 TEST_HARNESS_MAIN
-1
tools/testing/selftests/wireguard/qemu/debug.config
··· 25 25 CONFIG_KASAN_INLINE=y 26 26 CONFIG_UBSAN=y 27 27 CONFIG_UBSAN_SANITIZE_ALL=y 28 - CONFIG_UBSAN_NO_ALIGNMENT=y 29 28 CONFIG_UBSAN_NULL=y 30 29 CONFIG_DEBUG_KMEMLEAK=y 31 30 CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=8192