Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1674173pxp; Thu, 17 Mar 2022 14:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe9gtZO2jfQCCaNNveofwV/e5+yy65eWPMQcJDUKbEznZCKYeMeqOIdzrZUzJ6Qxcm8meR X-Received: by 2002:a05:6a00:1ac8:b0:4f7:55ba:95ef with SMTP id f8-20020a056a001ac800b004f755ba95efmr6671176pfv.75.1647551521075; Thu, 17 Mar 2022 14:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647551521; cv=none; d=google.com; s=arc-20160816; b=SOpkqjXvT1dSJGB4mCb5TyWPfryHvnIaQw+RWX613FDX+nhs+IvbjqZOK5uZv6wLf8 4xFeSK5+cudrkckIXX0oUvC46zNWooKk29/oK+r0/aj7pvRejMbwmNy04VH/d6/8rGRj GhznPf8qGkd/ZrAhw9EO1X0MpiszG9fhBMjSYpoEgufBcaOzrWMgwqnQCmn44Hy0gUYn 8im4hGMqTaj/sDrV2GUlLT96pL1JW70XuvdVKUVl2Yu8dTPM1oeqLLYfhbQL//7I9Ahb N15M2kJVuoFJ4XS/YkVDMhSsopyOIxrAUuSEgdzGtDUuOVkFNrPQgioimwHHcUJDWyBT 9VJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BgQnw+BqusxL9RJ+sc/8dhfcjQxpoNkAjiP0V+wfr98=; b=I39nn0ZLRviTHQXpBwIBeE2U7c2dUEjWBgIn8p/mtyB9KG6KTol4ugRfsxEH7+51jA /JdnuC8lyR0UQNVeH5dZ4Lu9N3mJTMUuuJxhVxouSZW4ggFn43g/5WJ07eihYtUrlDJD PTPM4EK/rSoLqWwsPoxsJIM4mjwT8Do+TUFhWlHx+h92/496Ec7bGLqcBiNzEa3yl77p 9YPrDwUwnkoUdecJ52DaOVF7yxd++7+AM+Ctn+jCGjR/fzyZchv5haJDUO8O+ncl6UIo oFJwHkt9cXvhUyLhWmHlzARoH6a6Qp4ZUDwjNpw8N6MjILsIR+HBRd1DzYgH0gvhmImD MPsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SYegcS9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 17-20020a170902c11100b00153b4c149a9si167112pli.624.2022.03.17.14.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 14:12:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SYegcS9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DA4B13018B; Thu, 17 Mar 2022 13:42:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbiCQUnb (ORCPT + 99 others); Thu, 17 Mar 2022 16:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbiCQUn3 (ORCPT ); Thu, 17 Mar 2022 16:43:29 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C65F10CF18; Thu, 17 Mar 2022 13:42:12 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id r13so13190062ejd.5; Thu, 17 Mar 2022 13:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=BgQnw+BqusxL9RJ+sc/8dhfcjQxpoNkAjiP0V+wfr98=; b=SYegcS9YNSU0vv5yR5gINCKQHpg+/XqF9+gzIf7ZIUFM9walUETQONunOSMMgl4HB2 zCqnFH2a7rhCGrTh1Vd3AzmjQIpEb90wh4ODtWjOGsvbblvHJAiEHynhL8EQTAcvsZbi V1zGzmg+B7NfQqJCIKFJZ9VA5NMyIQz2egBuKmwqdgV9kznKaBGpH1LqiYfu61QAVQZB sKNgB3Ci7KrFbhlulNrmxa7BptLiLsjn8Slde6S3yr6CKcwpfKMtlGM8zemRHjCh85wN GRAFLHNno3yHeVpsMMUXGvm3TslovFj+wa2UvbXpkOOIxN9L1LJuJxCSpJMtl/OV2CuY cV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=BgQnw+BqusxL9RJ+sc/8dhfcjQxpoNkAjiP0V+wfr98=; b=D+3hPt/cB0OKlekMYuHZmg9GqRUnc1NbaMVy11y5LDuK3dsjzuAB8MKDmmAzi2QxKn pOjYaqah2yw1aXmzyD0ohHFATLc/S9pojXQOkMX3uw3RQ5sKapML+6/5W1dfM+peQQy3 EFdGrrBl6DyK+N31/3mdIS7GWqGXX/p1W+tdANbg96EUF93I1G6KqOYQkgZPq07Sx6uu sRnDcI0ZhgD0+BqM/rxqCcOGCV64AfndCv/jNRPp0UDTVRycj6G60TRYE5yM1zb2Dgyn /7nxA8hlQ8Bo4Nmld4BAHzK71HjUtJJnTVLuh5C7O6y+xI2OM/oYnRaU8RdNtAFCkR/m bmuA== X-Gm-Message-State: AOAM5312gwCGikzi5DsIxsXxX3gjkeAI0MfRcL9zVQGiPDDvGP++mW9G Pa0ZsBsvAazvZaVT8alZDrue8UrziCfFhGjqhos= X-Received: by 2002:a17:906:7746:b0:6ce:a12e:489f with SMTP id o6-20020a170906774600b006cea12e489fmr5990415ejn.551.1647549731023; Thu, 17 Mar 2022 13:42:11 -0700 (PDT) MIME-Version: 1.0 References: <20220317140000.GO4285@paulmck-ThinkPad-P17-Gen-1> <20220317162033.GP4285@paulmck-ThinkPad-P17-Gen-1> <20220317173621.GQ4285@paulmck-ThinkPad-P17-Gen-1> In-Reply-To: <20220317173621.GQ4285@paulmck-ThinkPad-P17-Gen-1> From: Zhouyi Zhou Date: Fri, 18 Mar 2022 04:41:59 +0800 Message-ID: Subject: Re: RCU: undefined reference to irq_work_queue To: "Paul E. McKenney" Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, rcu , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Joel Fernandes , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi On Fri, Mar 18, 2022 at 4:20 AM Paul E. McKenney wrote= : > > On Thu, Mar 17, 2022 at 04:45:11PM +0000, Hyeonggon Yoo wrote: > > On Thu, Mar 17, 2022 at 09:20:33AM -0700, Paul E. McKenney wrote: > > > On Thu, Mar 17, 2022 at 03:24:42PM +0000, Hyeonggon Yoo wrote: > > > > On Thu, Mar 17, 2022 at 07:00:00AM -0700, Paul E. McKenney wrote: > > > > > On Thu, Mar 17, 2022 at 11:32:53AM +0000, Hyeonggon Yoo wrote: > > > > > > Hello RCU folks, > > > > > > > > > > > > I like to use minimal configuration for kernel development. > > > > > > when building with tinyconfig + CONFIG_PREEMPT=3Dy on arm64: > > > > > > > > > > > > ld: kernel/rcu/update.o: in function `call_rcu_tasks': > > > > > > update.c:(.text+0xb2c): undefined reference to `irq_work_queue' > > > > > > update.c:(.text+0xb2c): relocation truncated to fit: R_AARCH64_= CALL26 against undefined symbol `irq_work_queue' > > > > > > make: *** [Makefile:1155: vmlinux] Error 1 > > > > > > > > > > > > It seems RCU calls irq_work_queue() without checking if CONFIG_= IRQ_WORK is enabled. > > > > > > > > > > Indeed it does! > > > > > > > > > > And kernel/rcu/Kconfig shows why: > > > > > > > > > > config TASKS_TRACE_RCU > > > > > def_bool 0 > > > > > select IRQ_WORK > > > > > help > > > > > This option enables a task-based RCU implementation tha= t uses > > > > > explicit rcu_read_lock_trace() read-side markers, and a= llows > > > > > these readers to appear in the idle loop as well as on = the CPU > > > > > hotplug code paths. It can force IPIs on online CPUs, = including > > > > > idle ones, so use with caution. > > > > > > > > > > So the solution is to further minimize your configuration so as t= o > > > > > deselect TASKS_TRACE_RCU. > > > > > > > > They are already not selected. > > > > > > Good, thank you. > > > > > > How about TASKS_RUDE_RCU, TASKS_TRACE_RCU, and TASKS_RCU_GENERIC? > > > > TASKS_RUDE_RCU=3Dn > > TASKS_TRACE_RCU=3Dn > > TASKS_RCU_GENERIC=3Dy > > TASKS_RCU=3Dy > > > > > > > This means making sure that both BPF and > > > > > the various RCU torture tests are all deselected. > > > > > > > > I wanted to say call_rcu_tasks() can be referenced even when IRQ_WO= RK is not > > > > selected, making it fail to build. > > > > > > I am guessing because TASKS_RCU_GENERIC is selected? > > > > > > > Right. > > > > > If so, does the patch at the end of this email help? > > > > > > > No. did not help. > > > > I think I found reason... > > with PREEMPTION=3Dy, > > > > in kernel/rcu/Kconfig: > > config TASKS_RCU > > def_bool PREEMPTION > > help > > This option enables a task-based RCU implementation that uses > > only voluntary context switch (not preemption!), idle, and > > user-mode execution as quiescent states. Not for manual sele= ction. > > > > in kernel/rcu/Kconfig: > > config TASKS_RCU_GENERIC > > def_bool TASKS_RCU || TASKS_RUDE_RCU || TASKS_TRACE_RCU > > select SRCU > > help > > This option enables generic infrastructure code supporting > > task-based RCU implementations. Not for manual selection. > > Ah, this is because some of the tracing code uses TASKS_RCU only > when PREEMPTION=3Dy. That would be KPROBES and TRACING. Maybe also > TRACE_CLOCK and TRACEPOINTS, but I would hope that TRACING would > cover those. Adding the tracing guys for their thoughts. > > > > > > > ld: kernel/rcu/update.o: in function `call_rcu_tasks': > > > > > > update.c:(.text+0xb2c): undefined reference to `irq_work_queue' > > > > > > update.c:(.text+0xb2c): relocation truncated to fit: R_AARCH64_= CALL26 against undefined symbol `irq_work_queue' > > > > > > make: *** [Makefile:1155: vmlinux] Error 1 > > > > > > > > Isn't it better to fix this build failure? > > > > > > But of course! However, first I need to know exactly what is causing= your > > > build failure. I cannot see your .config file, so I am having to gue= ss. > > > > > > Don't get me wrong, I do have a lot of practice guessing, but it is s= till > > > just guessing. ;-) > > > > Sorry to make you guess. Maybe too late, but added config as attachment= ;) > > Perhaps I needed the practice. ;-) > > > > > It fails to build when both TASKS_TRACE_RCU and IRQ_WORK are not se= lected > > > > and PREEMPT is selected. > > > > > > > > =E2=94=82 Symbol: TASKS_TRACE_RCU [=3Dn] = =E2=94=82 > > > > =E2=94=82 Type : bool = =E2=94=82 > > > > =E2=94=82 Defined at kernel/rcu/Kconfig:96 = =E2=94=82 > > > > =E2=94=82 Selects: IRQ_WORK [=3Dn] = =E2=94=82 > > > > =E2=94=82 Selected by [n]: = =E2=94=82 > > > > =E2=94=82 - BPF_SYSCALL [=3Dn] = =E2=94=82 > > > > =E2=94=82 - RCU_SCALE_TEST [=3Dn] && DEBUG_KERNEL [=3Dy] = =E2=94=82 > > > > =E2=94=82 - RCU_TORTURE_TEST [=3Dn] && DEBUG_KERNEL [=3Dy] = =E2=94=82 > > > > =E2=94=82 - RCU_REF_SCALE_TEST [=3Dn] && DEBUG_KERNEL [=3Dy] > > > > > > > > Thanks! > > > > > > > > > > > > > > Or turn on IRQ_WORK, for example, if you need to use BPF. > > > > > > Or do you already have TASKS_RCU_GENERIC deselected? > > > > > > > No, this is selected. TASKS_RCU_GENERIC=3Dy. because of PREEMPTION=3Dy. > > OK, the patch shown below allows me to get TASKS_RCU_GENERIC=3Dn even > with PREEMPTION=3Dy. This might somehow subtly break tracing, but in > that case further adjustments can be made. Untested other than > generating a few .config combinations. > > Thoughts? > > Thanx, Paul > > ------------------------------------------------------------------------ > > diff --git a/arch/Kconfig b/arch/Kconfig > index 678a80713b21..66c5b5543511 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -38,6 +38,7 @@ config KPROBES > depends on MODULES > depends on HAVE_KPROBES > select KALLSYMS > + select TASKS_RCU if PREEMPTION > help > Kprobes allows you to trap at almost any kernel address and > execute a callback function. register_kprobe() establishes > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig > index f559870fbf8b..4f665ae0cf55 100644 > --- a/kernel/rcu/Kconfig > +++ b/kernel/rcu/Kconfig > @@ -78,7 +78,8 @@ config TASKS_RCU_GENERIC > task-based RCU implementations. Not for manual selection. > > config TASKS_RCU > - def_bool PREEMPTION > + def_bool 0 > + select IRQ_WORK > help > This option enables a task-based RCU implementation that uses > only voluntary context switch (not preemption!), idle, and > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > index 752ed89a293b..a7aaf150b704 100644 > --- a/kernel/trace/Kconfig > +++ b/kernel/trace/Kconfig > @@ -127,6 +127,7 @@ config TRACING > select BINARY_PRINTF > select EVENT_TRACING > select TRACE_CLOCK > + select TASKS_RCU if PREEMPTION > > config GENERIC_TRACER > bool I apply above patch, and invoke $make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- CC=3Daarch64-linux-gnu-gcc-10 tinyconfig $make ARCH=3Darm64 CROSS_COMPILE=3Daarch64-linux-gnu- CC=3Daarch64-linux-gnu-gcc-10 -j 16 kernel build successful this time (without above patch, kernel build will quit with undefined reference to `irq_work_queue' Tested-by: Zhouyi Zhou Thanks Zhouyi