Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1267629lfc; Wed, 1 Jun 2022 13:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYaQquVCZswCcKU3wR72Buvcjb7SZrTb/sItveAktxXpr/9TCevgszLQ7YoU7m+54l6uty X-Received: by 2002:a05:6a02:11c:b0:3f9:e159:5fa5 with SMTP id bg28-20020a056a02011c00b003f9e1595fa5mr1007407pgb.245.1654115866820; Wed, 01 Jun 2022 13:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115866; cv=none; d=google.com; s=arc-20160816; b=YibOGLvMP+UEBt3hItZWHJQvwHiCjacdnExPVEUeGyhfyZxUIoWUATawhWgWVpZsJG qOUg3EgXXRCSjIcH533UfOhfLxtwK7lZGk0jlt2MSZiQmmL7Ss6f7rHWg8fk/G+h4ozL 5g9B/UBkKLrbonu7KDNJ3nbsD+ftbEGo6tavE3V7xuu/borhAUGPE5cvMMQhIkuDmEvY VaQqOXMOpf/v5aiqYGoBjyjw1Rlmm2ficIGnwP1N3zIhIv5ppAHU8j3JmGYeVqUGAqaX rGSd6Vuzz0Fkr7qU8yMhTS2fGe92sFTk4I0q4Q9JSc3cnE2gUu/3KbaXP7spL+uuA5Dk OPfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7F+sRYtqzAK7Qkdkt1STsL6rqDcnBDbLPwNMgaDX6KA=; b=SOVhlP+Ris/3nZ2I5P8PbovTf+/tc78xMRLhy9P2hCv7O/A3u0upK87GtpRr5CK7Wv eiB6bKlfcp2PQCl7/p7HLcjNtyROUsM81KXrPt96Mw29vQqbzmN/05hgJWh6UUmbyzwo IQbLn6x6ifE9GDIcFFiGGdDZR7xC3oo1fKDLmXqzqCngvLaaiiN1Z1GDURp+uXnQo6dU yJ7lQWiV1sRJBSZLmktIeHlRlcPT5SoNdaY8CKB0NmK9UZajE4U4PwxezIINThzkee9s +vSn5b8c40jCOP1CNudgNe+JmKUEvZbOCRrzvFYg6GCZrgtlRqzVnwNSRHaXdios0lLz SDHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KqvNcoUn; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w11-20020a170902e88b00b001614cd997a6si3996583plg.481.2022.06.01.13.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:37:46 -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=@redhat.com header.s=mimecast20190719 header.b=KqvNcoUn; 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=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3FE2287593; Wed, 1 Jun 2022 12:46:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355848AbiFAPts (ORCPT + 99 others); Wed, 1 Jun 2022 11:49:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355859AbiFAPtq (ORCPT ); Wed, 1 Jun 2022 11:49:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 301C1A5013 for ; Wed, 1 Jun 2022 08:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654098583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7F+sRYtqzAK7Qkdkt1STsL6rqDcnBDbLPwNMgaDX6KA=; b=KqvNcoUnTWi/JrgOvk0EWw14d3T/S5TVjsY7rVtTcF07CEWaR60BzE1EqlZ39h1BVR7Oud O38qHsEQye1S/IqKNXZktPyvHbs7a++jluoqCHQsUSi8VagAvH3z/A0dIN/JVX7b09t4ap bwS25xK+yQR21QI5m3zSorXWmepb2HQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-W91-SlZbPDiEhWenD0nv2w-1; Wed, 01 Jun 2022 11:49:39 -0400 X-MC-Unique: W91-SlZbPDiEhWenD0nv2w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 963EF2A59546; Wed, 1 Jun 2022 15:49:39 +0000 (UTC) Received: from lorien.usersys.redhat.com (unknown [10.22.19.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4145A40885A2; Wed, 1 Jun 2022 15:49:39 +0000 (UTC) Date: Wed, 1 Jun 2022 11:49:37 -0400 From: Phil Auld To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra Subject: Re: [PATCH v2 1/2] cpuhp: make target_store() a nop when target == state Message-ID: References: <20220526160615.7976-1-pauld@redhat.com> <20220526160615.7976-2-pauld@redhat.com> <20220527132156.GB26124@pauld.bos.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Mon, May 30, 2022 at 01:27:00PM +0100 Valentin Schneider wrote: > On 27/05/22 09:22, Phil Auld wrote: > > On Fri, May 27, 2022 at 10:38:24AM +0100 Valentin Schneider wrote: > >> On 26/05/22 12:06, Phil Auld wrote: > >> > writing the current state back in hotplug/target calls cpu_down() > >> > which will set cpu dying even when it isn't and then nothing will > >> > ever clear it. A stress test that reads values and writes them back > >> > for all cpu device files in sysfs will trigger the BUG() in > >> > select_fallback_rq once all cpus are marked as dying. > >> > > >> > kernel/cpu.c::target_store() > >> > ... > >> > if (st->state < target) > >> > ret = cpu_up(dev->id, target); > >> > else > >> > ret = cpu_down(dev->id, target); > >> > > >> > cpu_down() -> cpu_set_state() > >> > bool bringup = st->state < target; > >> > ... > >> > if (cpu_dying(cpu) != !bringup) > >> > set_cpu_dying(cpu, !bringup); > >> > > >> > Fix this by letting state==target fall through in the target_store() > >> > conditional. > >> > > >> > >> To go back on my data race paranoia: writes to both cpu$x/online and > >> cpu$x/hotplug/target are serialized by device_hotplug_lock, and so are the > >> exported kernel hotplug functions ({add, remove}_cpu()). > >> > >> That's not cpu_add_remove_lock as I was looking for, but that's still all > >> under one lock, so I think we're good. Sorry for that! > >> > > > > Right. This catches it up higher so that we don't get into the code that > > starts actually changing things. I wonder now in the state == target case > > if we should make sure st->target == target. With the second patch it's > > less likely to be needed. Thoughts? > > > > Yeah, you could append a simple: > > else > WARN_ON(st->state != target); I was thinking more like: else if (st->target != target) st->target = target; Since this is a write to the target field and we are not doing one of the operations that will set target because state == target we should make sure target == target. Although that could have its own issues, I suppose. But as I said fixing the boot cpu should make it much less likely that st->target != st->state once we have the hotplug lock. I don't see how that WARN would ever fire. We're under the lock and nothing is re-reading the value of st->state anyway. Looks more like a compiler sanity check :) Cheers, Phil > > Maybe I'll include that if/when I have code to keep cpux/online in sync > > with st->state and cpu_online_mask. > --