Received: by 2002:a25:d80c:0:0:0:0:0 with SMTP id p12csp11690ybg; Tue, 9 Jun 2020 14:28:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTf98gw5cpl9GV1a324ESCU0cvcgpcxzyW0gjjZ/LfJKE83dVyS+lmGbpebpW/m2hWajn2 X-Received: by 2002:a17:907:20db:: with SMTP id qq27mr363531ejb.232.1591738128714; Tue, 09 Jun 2020 14:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591738128; cv=none; d=google.com; s=arc-20160816; b=brWnTx4x11/R/pecl11MNb1bwPoipGZ63L+AkAKqku8yDahry7cGu5M4hGnuxJSxje nYH7PxvLN+rva/jflFShCmSDt+FjuwUsiR28JQOirsxOoYUuC//M7h9L6um1a/BS8+Be OQjWJSC2BRWq8VOD9iSqkuDI4BdMwa9y1yfblQA336Man8j3KOHXL3Fp8DiKkAbgOoWS 2G5c3kBMZ48Mv8EGt2D2m6YDfdIA2fQyh5q7ETFiGxmL82+E1lMv5qLqHLPF4sQnpadL 0Q31kBcTacBqr+4j9ydzM16VnLwISNCzoGqtj7XE360S6l1oFH2YA9yX0Y8k2gWXggoQ dciQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XZSHPao27jDaviX/CgUO6zfDPdssCrcO3HslKSHh6h0=; b=ilOLj7V9HEckeqJZuXO5tLCp7hhddesq6B+QmZw1GIPPHZFmwoPYfswo2puzc1u00Y wM4V9N7JgF+CJfw4GB9krKLLlRbho9NPgw5d4fewvhedReMpwILnkLDNIpYFtE/gpwEb ZYMAyjRIS12rUlKzI21WPnDP88oYDJOYprgaD60flfgIIiGjBuV9ANEHqDKBOk7TrQe4 9fETmh5tGcNHRRFCbzMi/dyZgct+GSV5y2eOirjk45zWMlqgoQ693U79G40OmDE3N6Eb IbpE7LVKhdPJBLQ9DK8Rhzm/fw8aV61AevJBkqgeOTRTO8ZlApy+IMM2ZLuZOeTs0o45 o7zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QxV4uRKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si5163190edq.385.2020.06.09.14.28.25; Tue, 09 Jun 2020 14:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QxV4uRKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbgFIVZQ (ORCPT + 99 others); Tue, 9 Jun 2020 17:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbgFIVZM (ORCPT ); Tue, 9 Jun 2020 17:25:12 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAEFFC05BD1E for ; Tue, 9 Jun 2020 14:25:12 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x11so78233plv.9 for ; Tue, 09 Jun 2020 14:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XZSHPao27jDaviX/CgUO6zfDPdssCrcO3HslKSHh6h0=; b=QxV4uRKuGPPTyAvE8pmG+djgl4hq4n/9yAM3mrLlhk/dEHgXYUSStvIs4NhPp+Q38o alLylDOM42ECtSoRKYjdc+dSYqccciiquc10woGnL+viYPDGflKr+bA89ovf+0MBlq5X vf1q1SZs+ot83CixIR7nXx6vvcKUoJ2dXhL1C1YXrKeamjN41odMMkHvrqqQs/BtpiN5 bsizwYYdtBGrkGyes9753IaTmx2ZCwQu/hpkljG9/x+m/GXOyAX5lxx0OK58VHJ1MHEY qlCKiowvBBuH8r389kBOPFV/4qRfO6CPT6BE0T0FUnZBjmJ33CiMaB3OmjSLyPWQnXjD g5CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=XZSHPao27jDaviX/CgUO6zfDPdssCrcO3HslKSHh6h0=; b=ZCqnUNJXwDGzLKwXsRxG0PAsROkljZUrhZztu0TR3nvIhwtZEP+hLRnBcxXiECsu0K hNKkPoN03gM93Yxy9m78rvOFyKZgp5ZxqEp5I39WLh2mypbviI6rRgtq87oNb9Lq/piS 5n+PIFzoBLmUKeU+6bdaIRDaVaBCnfVwQHXsoAHy9fHgVc211QfSs12Ub3bsEEBQ6ZM/ ne+oha2xgQXjyxwtitBWNgMWS4/wTSPx005f1YquC1rckQHz4qDkYzfK46engu9qM2/K MDO9odjsNt2f2C3FGakwWhXNov4fBf0KDX/+63PJV1jRezXy4G9TKIyDqxajd1UPCgrq 6Zqg== X-Gm-Message-State: AOAM530xvIILqlRqqYcNLGfTpMcjOYTaH/6Yi0I4GjBi00oOHLkP/tYh Ie5RwqpaLFC5Ic5mYJ+5wbg= X-Received: by 2002:a17:90a:cb8d:: with SMTP id a13mr6853219pju.175.1591737912192; Tue, 09 Jun 2020 14:25:12 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d5sm3252388pjo.20.2020.06.09.14.25.10 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jun 2020 14:25:10 -0700 (PDT) Date: Tue, 9 Jun 2020 14:25:09 -0700 From: Guenter Roeck To: Eric Biggers Cc: Peter Zijlstra , tglx@linutronix.de, frederic@kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, cai@lca.pw, mgorman@techsingularity.net Subject: Re: [RFC][PATCH 7/7] sched: Replace rq::wake_list Message-ID: <20200609212509.GA239889@roeck-us.net> References: <20200526161057.531933155@infradead.org> <20200526161908.129371594@infradead.org> <20200604141837.GA179816@roeck-us.net> <20200605002433.GA148196@sol.localdomain> <20200605074154.GB2750@hirez.programming.kicks-ass.net> <20200605161532.GD1373@sol.localdomain> <53318971-561c-b445-0408-530b3d3ba44e@roeck-us.net> <20200609202134.GA1105@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200609202134.GA1105@sol.localdomain> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 09, 2020 at 01:21:34PM -0700, Eric Biggers wrote: > On Sat, Jun 06, 2020 at 04:13:33PM -0700, Guenter Roeck wrote: > > On 6/5/20 9:15 AM, Eric Biggers wrote: > > > On Fri, Jun 05, 2020 at 09:41:54AM +0200, Peter Zijlstra wrote: > > >> On Thu, Jun 04, 2020 at 05:24:33PM -0700, Eric Biggers wrote: > > >>> On Thu, Jun 04, 2020 at 07:18:37AM -0700, Guenter Roeck wrote: > > >>>> On Tue, May 26, 2020 at 06:11:04PM +0200, Peter Zijlstra wrote: > > >>>>> The recent commit: 90b5363acd47 ("sched: Clean up scheduler_ipi()") > > >>>>> got smp_call_function_single_async() subtly wrong. Even though it will > > >>>>> return -EBUSY when trying to re-use a csd, that condition is not > > >>>>> atomic and still requires external serialization. > > >>>>> > > >>>>> The change in ttwu_queue_remote() got this wrong. > > >>>>> > > >>>>> While on first reading ttwu_queue_remote() has an atomic test-and-set > > >>>>> that appears to serialize the use, the matching 'release' is not in > > >>>>> the right place to actually guarantee this serialization. > > >>>>> > > >>>>> The actual race is vs the sched_ttwu_pending() call in the idle loop; > > >>>>> that can run the wakeup-list without consuming the CSD. > > >>>>> > > >>>>> Instead of trying to chain the lists, merge them. > > >>>>> > > >>>>> Signed-off-by: Peter Zijlstra (Intel) > > >>>>> --- > > >>>> ... > > >>>>> + /* > > >>>>> + * Assert the CSD_TYPE_TTWU layout is similar enough > > >>>>> + * for task_struct to be on the @call_single_queue. > > >>>>> + */ > > >>>>> + BUILD_BUG_ON(offsetof(struct task_struct, wake_entry_type) - offsetof(struct task_struct, wake_entry) != > > >>>>> + offsetof(struct __call_single_data, flags) - offsetof(struct __call_single_data, llist)); > > >>>>> + > > >>>> > > >>>> There is no guarantee in C that > > >>>> > > >>>> type1 a; > > >>>> type2 b; > > >>>> > > >>>> in two different data structures means that offsetof(b) - offsetof(a) > > >>>> is the same in both data structures unless attributes such as > > >>>> __attribute__((__packed__)) are used. > > >>>> > > >>>> As result, this does and will cause a variety of build errors depending > > >>>> on the compiler version and compile flags. > > >>>> > > >>>> Guenter > > >>> > > >>> Yep, this breaks the build for me. > > >> > > >> -ENOCONFIG > > > > > > For me, the problem seems to be randstruct. To reproduce, you can use > > > (on x86_64): > > > > > > make defconfig > > > echo CONFIG_GCC_PLUGIN_RANDSTRUCT=y >> .config > > > make olddefconfig > > > make kernel/smp.o > > > > > > > I confirmed that disabling CONFIG_GCC_PLUGIN_RANDSTRUCT "fixes" the problem > > in my test builds. Maybe it would make sense to mark that configuration option > > for the time being as BROKEN. > > > > Still occurring on Linus' tree. This needs to be fixed. (And not by removing > support for randstruct; that's not a "fix"...) > How about the hack below ? Guenter --- diff --git a/include/linux/sched.h b/include/linux/sched.h index c5d96e3e7fff..df1cbb04f9b3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -629,6 +629,15 @@ struct wake_q_node { struct wake_q_node *next; }; +/* + * Hack around assumption that wake_entry_type follows wake_entry even with + * CONFIG_GCC_PLUGIN_RANDSTRUCT=y. + */ +struct _wake_entry { + struct llist_node wake_entry; + unsigned int wake_entry_type; +}; + struct task_struct { #ifdef CONFIG_THREAD_INFO_IN_TASK /* @@ -653,8 +662,9 @@ struct task_struct { unsigned int ptrace; #ifdef CONFIG_SMP - struct llist_node wake_entry; - unsigned int wake_entry_type; + struct _wake_entry _we; +#define wake_entry _we.wake_entry +#define wake_entry_type _we.wake_entry_type int on_cpu; #ifdef CONFIG_THREAD_INFO_IN_TASK /* Current CPU: */