Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2961075lqz; Wed, 3 Apr 2024 13:44:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxq17an/jWmJ//KGBHuXX/fMZmWwZ7bD/XgZA6V19gzM5fYp8/XzJdV5ZW4oBaFjFviGOxa5NZVXqb8RaxEXN6AgHtnuBxLKLDzwKilQ== X-Google-Smtp-Source: AGHT+IF5YUE+KPo6MnY9NE2jMpJDt9qBCr6wWHglVA+B7YKtgSzbZWoC2HkAkWs0qyEhZKQ9YJlz X-Received: by 2002:a05:6214:518d:b0:698:ec7c:b708 with SMTP id kl13-20020a056214518d00b00698ec7cb708mr511725qvb.5.1712177097315; Wed, 03 Apr 2024 13:44:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712177097; cv=pass; d=google.com; s=arc-20160816; b=TvM5YetxBf5il+Eg56Mv6O+fxQuERhdIGwcMyMZwXy21BXmF0PG+X0FqxI3DJp7YzT qdtLMY2RBzS/lPR2IfT/XS7cJbIKASgvzwDlmNcHr7xD3t6NHBPXzfmNrmNeyLH5Hn3I BhzaefkVuAlEj5Jz55edLawaKSuV+8HAGO4Fh4af6FU24YG3wtCbM2M+lLPzGSwHaOf4 lzMuKueJyBfUWD/wfuCXoo9poD0sGPc0BhONKqG6+6bNKrbf7S/0ChZb6pqNEeT7TfUh ATS7toPcqYfD8soASre99AXvJw3F/9cdlR5dV642+Hp5PUCkZKuMyYTM9zb7oAKUHez2 SuSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=10W1a6ACeEYknqtbR5jDT5gL3yupRWkQ7v3GNEKtOOo=; fh=mJoSi19194ilOkb1cVnsqfKX8sm/9ZNfhVxDFg7RlL4=; b=jVHFv+ZiwLAbiwcZVDOOLXCIW6VELN5UUcejPVfxei6QrPjksAKxHiQzYyRRoqV0dn hmw2qoqFTfm515BwiuZ5PyHQqvs+1eBV9hMHJQUyMbr2JKoOTcBFSIOgwQtPEezXHalg wetY4q7FdPVw3mriaoQOI+ugon4p9hAWMpCsKwsKFzg1xTERuwjMMrqBFsTBor1OgbRZ Xkv4zgNcHXD8Up1zRtTI/qk5AYCJ795NUelaf2PEwHtRaykzBFfOb9/BheoxiwbJbJua BShE/zQaTIg5G+wWnQlaBlQ/woyyIrCvOTcWEiWgu8NFBaezWr6QBnsoqmfyb5kRD7Of snqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sfor8slN; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-130591-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130591-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k17-20020a0cc791000000b006910a72721dsi14541361qvj.230.2024.04.03.13.44.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 13:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130591-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sfor8slN; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-130591-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130591-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8523A1C25BBA for ; Wed, 3 Apr 2024 20:44:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FD8315696E; Wed, 3 Apr 2024 20:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sfor8slN" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71335155A59 for ; Wed, 3 Apr 2024 20:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712176791; cv=none; b=aQ+LOQ5AOnnzX5XToS4NHSxSNBpqtfw5VuURhgqdhSMTQ2rP+39IaPze9lAsLfYW2Y0ks7LpR2ya7sd1EMHAFBiHbZ8qk4/V9ICTmSOQS6QhKiREE+EF77yPdwLV52e6FMyrO2NLeP4b6atqBf4SsIthKFO6lW4jFHYeJj1Xeh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712176791; c=relaxed/simple; bh=eOi+5WikSTorjSEPPxKitefyYKeYvbuIEeHrzNbFRQg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RbmdWqrMcs9pJVpTyTELeDWwA5dxHP8sX1XNxVVaDNioCv1PiUy3ud8uvQaLOor2QKLQvVYfz8Kfgk4imFH3QyL4Uvm4U/9vSJJkrqwS3tyDVn9+DwbQ1CZQTn7CaiwWh1EllfUWsDkbsNnHFP/IIb3HquQpH5dbDp4KTmZp5R0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Sfor8slN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712176788; 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=10W1a6ACeEYknqtbR5jDT5gL3yupRWkQ7v3GNEKtOOo=; b=Sfor8slNidH6RapnnZfX/s1/kwR9H4SCRJ9aqpR1PeSe6p9zqs/6TxrmWDuUlIvcO29U7g HZs9E1koVWdhuunNsLvQcJgfXG7njK4c/0dI6O/drCCMGXnFHeoUUOH9SlVjP4pECe0MrO yWkUKRm84o5erktw/+PZmOxTtqj3Fdg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-EfadVLGUMnSNE28BtlkcVA-1; Wed, 03 Apr 2024 16:39:47 -0400 X-MC-Unique: EfadVLGUMnSNE28BtlkcVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4C6D863012; Wed, 3 Apr 2024 20:39:46 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.49]) by smtp.corp.redhat.com (Postfix) with SMTP id 0E24D2166B32; Wed, 3 Apr 2024 20:39:43 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 3 Apr 2024 22:38:22 +0200 (CEST) Date: Wed, 3 Apr 2024 22:38:14 +0200 From: Oleg Nesterov To: Tejun Heo Cc: Leonardo Bras , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Lai Jiangshan , linux-kernel@vger.kernel.org, Junyao Zhao , Chris von Recklinghausen , Frederic Weisbecker Subject: Re: [PATCH v2 1/1] wq: Avoid using isolated cpus' timers on queue_delayed_work Message-ID: <20240403203814.GD31764@redhat.com> References: <20240130010046.2730139-2-leobras@redhat.com> <20240402105847.GA24832@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Hi Tejun, On 04/03, Tejun Heo wrote: > > (cc'ing Frederic and quoting whole body) > > Hello, Oleg. > > On Tue, Apr 02, 2024 at 12:58:47PM +0200, Oleg Nesterov wrote: > > This patch was applied as aae17ebb53cd3da but as Chris reports with this > > commit the kernel can crash at boot time because __queue_delayed_work() > > doesn't check that housekeeping_any_cpu() returns a valid cpu < nr_cpu_ids. > > > > Just boot the kernel with nohz_full=mask which includes the boot cpu, say > > nohz_full=0-6 on a machine with 8 CPUs. __queue_delayed_work() will use > > add_timer_on(timer, NR_CPUS /* returned by housekeeping_any_cpu */) until > > start_secondary() brings CPU 7 up. > > > > The problem is simple, but I do not know what should we do, I know nothing > > about CPU isolation. > > > > We can fix __queue_delayed_work(), this is simple, but other callers of > > housekeeping_any_cpu() seem to assume it must always return a valid CPU > > too. So perhaps we should change housekeeping_any_cpu() > > Yeah, patching this up from wq side is easy but housekeeping_any_cpu() > always being able to pick a housekeeping CPU would be better. > > > - return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); > > + cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); > > + if (cpu < nr_cpu_ids) > > + return cpu; > > > > ? > > > > But I'm afraid this can hide other problems. May be > > > > - return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); > > + cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); > > + if (cpu < nr_cpu_ids) > > + return cpu; > > + > > + WARN_ON(system_state > SYSTEM_BOOTING); > > > > ? > > > > ------------------------------------------------------------------------------- > > OTOH, Documentation/timers/no_hz.rst says > > > > Therefore, the > > boot CPU is prohibited from entering adaptive-ticks mode. Specifying a > > "nohz_full=" mask that includes the boot CPU will result in a boot-time > > error message, and the boot CPU will be removed from the mask. > > > > and this doesn't match the reality. > > Don't some archs allow the boot CPU to go down too tho? If so, this doesn't > really solve the problem, right? I do not know. But I thought about this too. In the context of this discussion we do not care if the boot CPU goes down. But we need at least one housekeeping CPU after cpu_down(). The comment in cpu_down_maps_locked() says Also keep at least one housekeeping cpu onlined but it checks HK_TYPE_DOMAIN, and I do not know (and it is too late for me to try to read the code ;) if housekeeping.cpumasks[HK_TYPE_TIMER] can get empty or not. Oleg. > > So it seems that we should fix housekeeping_setup() ? see the patch below. > > > > In any case the usage of cpu_present_mask doesn't look right to me. > > > > Oleg. > > > > --- a/kernel/sched/isolation.c > > +++ b/kernel/sched/isolation.c > > @@ -129,7 +154,7 @@ static int __init housekeeping_setup(char *str, unsigned long flags) > > cpumask_andnot(housekeeping_staging, > > cpu_possible_mask, non_housekeeping_mask); > > > > - if (!cpumask_intersects(cpu_present_mask, housekeeping_staging)) { > > + if (!cpumask_test_cpu(smp_processor_id(), housekeeping_staging)) { > > __cpumask_set_cpu(smp_processor_id(), housekeeping_staging); > > __cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask); > > if (!housekeeping.flags) { > >