Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1341836ybg; Thu, 4 Jun 2020 07:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz8I11ue/Yb3d501yyWYs9xC5MqyzK3fjlbd6Hg6Ong5WaskzP8QVPBxlGjM6p6JXn7gt6 X-Received: by 2002:a17:906:1917:: with SMTP id a23mr4043219eje.181.1591280614203; Thu, 04 Jun 2020 07:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591280614; cv=none; d=google.com; s=arc-20160816; b=PuhFkknUk84u1b4eRSRXiSSMtVzV229ks725ND4W6edH7T6QyXS2+qkL9XBF/QIL7+ VmdGrv3VtS6Q+pDKsTUxWQPhj8cyf/OZJQY1ZXh7NgSBfsJ7zHD58pBJeHqjHQ+55qRL 3fAva4fvRLpMNAUmDKmIhPVKSQ39yoEpfXSvAlH2nICD8j/xTrlEBeDn/AjPQj9Pbt4S KquRuXsT9p34q/yII6aHs4KAjG351OJG7kGuueCECO+lnvHGeqB6KN0tB0ZyTEnJM30x Joi5NPWHL+Pp6pspUm9M6edvkEazhztf3jcuvxR4qv2A3kJ2KLpk2Betg9RjGshB156a pVRQ== 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=Ri5FBTpEA9YkaHeCTU7jHRHoP9LrYKT9s+Qg6K61SSU=; b=0fus/kwAA65QNnormIM0AKL8zVQrHlq8SJ8K/uBmIx/+Pa+1f85MLXDySHIkchZYxX VEkYLRK6+l8YMnIrHp22v7QEw4vKP8eEpRF3YcTsMd00ImATvPLb/ngfIg1r6B/SoMUZ Ps80USUqRc+Rv6WqzfbszYwdZDQ7LgaOjTMZ8Iu0FOYoa9cg11ky2x/ccFN90xtWX4A5 PJobl/PQaHzNSzGh8lwK3EqT0N313LYnagLAKNwMLJXvhV6khVtYIMUKD+OZ+4r5m3X/ i4W64guBr5FyYwgZKcoKoXCPfTkVv73xGmmXopqU3Rek2xjy6oaxGaZ+se001idPFybX dhLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rh72YHVB; 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 p18si1668517edm.288.2020.06.04.07.23.10; Thu, 04 Jun 2020 07:23:34 -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=rh72YHVB; 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 S1728975AbgFDOSk (ORCPT + 99 others); Thu, 4 Jun 2020 10:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728496AbgFDOSk (ORCPT ); Thu, 4 Jun 2020 10:18:40 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CFEC08C5C0 for ; Thu, 4 Jun 2020 07:18:40 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ga6so1190358pjb.1 for ; Thu, 04 Jun 2020 07:18:40 -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=Ri5FBTpEA9YkaHeCTU7jHRHoP9LrYKT9s+Qg6K61SSU=; b=rh72YHVBIfH9tw+L1kUlcM7Gq/mLJMS3+FLS011d4U4EHYjFhYed5pAMZOrrS35TDy ziqKm6a1hFMWKMKBv/TW1yJnTuWOg95Sphq/viB24eiJH22UNKtUOtuKIVErog1M5bJ/ FzlAefLQwQsbyvajmM5QKNVZg/6Ju6bnVmJsJsgMJK0CjofaseMTQFZT1OTFCNYetQ2i WVzxbXQPDE91syM+ApsKN7hpEUvTcUCotpraQ8pwzCCsLrSl+rfAZ+4hMSFBn+SkBOwf OcZCkFkTJWjzzjLjppuVPL34sHWWK2nOoZDBWJyB+GdWUi5u8inTSN0vOC5ORhLzmZKj Tp7w== 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=Ri5FBTpEA9YkaHeCTU7jHRHoP9LrYKT9s+Qg6K61SSU=; b=j30/upJWiEKuX+OgX+v4m4ZUx85JXJcnijaUjWTGHt2oreTT/bDMe+03fPyhDf1bhI hLCj3TJsHTLMBgQal5I6XqAKoZnGa7Nomc0rG0PXwnkzIXt0S/Ezsi9+6mmJQ1LEQHEV dQJ+0hosTfdv7XpKt2SvRorS5gruyE8nhAjkYAz5qUGFabXe1dwII4vhDNZNjvuQ/Cur 22yzg+RQEqqjXXc6LubQztxB/N/O8gPowOw/+arpPfuNFcNhv0rt1NukDGmCqL+4a29y 148vNKudblZc1VWWLKWALC5qXMo0T6YtNXxwHIC9pFoHYic9cvKZhRlt48+7gyM3R/Kk Qj+w== X-Gm-Message-State: AOAM5326oQNH7imhue1UJlznmdGmxu+ShR4qZ7T0I1XQLfJDIX9GVt/0 F5nT9Gk0XesQQnFJCCVX0Ig= X-Received: by 2002:a17:902:a711:: with SMTP id w17mr5026271plq.173.1591280319828; Thu, 04 Jun 2020 07:18:39 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v22sm5165951pfu.172.2020.06.04.07.18.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jun 2020 07:18:38 -0700 (PDT) Date: Thu, 4 Jun 2020 07:18:37 -0700 From: Guenter Roeck To: Peter Zijlstra Cc: 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: <20200604141837.GA179816@roeck-us.net> References: <20200526161057.531933155@infradead.org> <20200526161908.129371594@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200526161908.129371594@infradead.org> 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, 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