Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2255971ybg; Fri, 5 Jun 2020 09:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyInuTf8Gw3+0REUmxvLsMhU5V4yw3Qz8YsI55IpNqbfvBJ2IBZaAnY7cmQZMI4TIrjIFxu X-Received: by 2002:aa7:c790:: with SMTP id n16mr10456032eds.54.1591373883165; Fri, 05 Jun 2020 09:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591373883; cv=none; d=google.com; s=arc-20160816; b=T6+hk8m8xwXLisuh5XIW/DBbi93JV8NXAGVNpsYB7gUZno9CppAmYSrPlocX1qudKR 1lC0HvnhbYp0qeEMejxC4AOc6vToNj8Dhm6hbrPXNip7OXHfndSST60RGfHq4EXbUEjR HmhZ83uRwIJmW+rN9H9c3P2slBBpNC5geVfYDlty42dRhPFjDyV1YYzqLmSEodeYuzUS PWEuzFKWeMv3MkXyE5MurlUCdrr+n85n86QvQ5TU32lFGU4D0ydzK5GDzznS6mBd4dGV rxJtwYaF2cgADOULZFaDTpFUbfNiRnyWhwwNQS5mbtXTr/HY1XlE4SaqviefNAqpHjP6 0RFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=skXv0i7IJSgivSaf4Q/8qUVE8UiHGuu0fjk600i00RM=; b=GaglGijXC7HN7O6A13SC2HzVppL48Yw4I0ffcUlWM/agspUXq0MRhy37QkbmMFzdNx deoJKRk2zi7poR2BfdLrZkkDadASNuHmOdy/L523QXdRHqjwHReadEzvkfLou12Hws10 F8Z67R3EvSBeeaTqCj0hO3+CeYD9A+j4KAUl03kr7zB7IdP7iupbmDBZ5I27SjtWFxfI 663VkwqFv57pQ8x38IbsW3rLZqxHoETO9CNMQUfqL2d0/ODJXYqOC2wiRPZ5mlj5ATDF jiAC/L46y84rZuTEJ43nuH3B9rYmvl/Mdm7BnXiw6SJrJy3cLcmKHVXFw2UbjybSjtP+ kLmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zLKsDwLm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce13si854642edb.81.2020.06.05.09.17.40; Fri, 05 Jun 2020 09:18:03 -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=pass header.i=@kernel.org header.s=default header.b=zLKsDwLm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgFEQPe (ORCPT + 99 others); Fri, 5 Jun 2020 12:15:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgFEQPe (ORCPT ); Fri, 5 Jun 2020 12:15:34 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 15D77206DB; Fri, 5 Jun 2020 16:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591373734; bh=UwdpKRdlqrxAPQ+pD6xjKA3W+jwOlZ4r03LkFTrY1LA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zLKsDwLmu6PneMG+VwHwZGHKoOyzHO9TL8dnMZwSDzM56f4c2gTVNNn9RdcetnCyC vYZVmspRNN7G+itrwzjpyfg3EA09W5ypfcsrmNcpmucq3faJwn/+LmwwkTKW4f/NHG 5MGycP4gFgaj6ueu/XoxPOxE9/G0S+ATeGVhNFsE= Date: Fri, 5 Jun 2020 09:15:32 -0700 From: Eric Biggers To: Peter Zijlstra Cc: Guenter Roeck , 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: <20200605161532.GD1373@sol.localdomain> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200605074154.GB2750@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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