Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp155324rdb; Wed, 17 Jan 2024 22:15:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ1M3/SkBnNrKxG5PDtwLpQ8CQqFnwFIwVmU52ALN0Gs2T9xsLkO/QuNm0XxbEFIL9Ojmk X-Received: by 2002:a05:6808:1812:b0:3bd:829c:996d with SMTP id bh18-20020a056808181200b003bd829c996dmr444913oib.68.1705558543231; Wed, 17 Jan 2024 22:15:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705558543; cv=pass; d=google.com; s=arc-20160816; b=ohub7yQ2UywP6ArQ/RssCj0Q9AeC3wcFuvE66ppwK3zEqdHtzGDMRb/tPDHj3tcNli Iz4GcYlHxA1ENDl8wLQmgSDfVHRQyDpUTcdypHIbuKERsCud1hpk6e8sSRNLiz7PLUe3 RQ/8r3nz8ufNJ2h9vaYaVtyIjgVCSw6g/PRCPZvddVkWWPZwnsUifRj7YhTXYDMMBDah qeOUkfkshtBRb4GllQbKavoENJVgjAOQB9mKKjfIumT1IgUJ7wCOpnOfCpV8FyPQGW2J e73yJNiaMfjMB864ZucSemTz6RfrvW7banLSP6wh+AovGHc4jWGLSn2Gs+qkub6DH6VP i62g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=mh84LK5Hn0va2aqVidMrgA/rXrDauaZUcxawgJ4ahFA=; fh=Dv5cYZQZNwbLyFYiWq7SCjNLhbTwwwmT6+vdvekx4Q8=; b=lWmft9AJYLTvbSLOAMYAUNoLermHyxbw8vm37acizBpbqXKEoODX8wnJVTWECBfA3S yBvSLy0gP/yEIj7HbYhS6NDTcUXsZPSsNahxbJpkC2MDKq5znskyAl0ago9PcLulqhFk JQQxABSfRY88+tRjYVkzOy0PgXWUoeD4qpNLjwcAVhgaprVlXjSlSSvci3NnOVdwjXWr g6DBmiLrFzT8uUtJ+hwP+DPbqKi8xQIQC9hfyPF1zL/InrD9Hn5glx80PKYa/MDnKhDK f5zmnZQDnq/fD7mPC6wzQg841KfS/5qq4KYQOvGZaBmaMlvfOJ1GhxtHUPIxTijSOZJh /l1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cl5mJQEP; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 9-20020ac85749000000b0042a0c933d1fsi3286991qtx.516.2024.01.17.22.15.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:15:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cl5mJQEP; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 E2B1F1C22192 for ; Thu, 18 Jan 2024 06:15:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4975D8F6F; Thu, 18 Jan 2024 06:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="cl5mJQEP" Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 E7B90B641 for ; Thu, 18 Jan 2024 06:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558534; cv=none; b=as6fMfBPOBLPVeCpqrcx5PJ/fta/EyppDA0NuTiHQuf+bt7FyE06zLDoAWGbi2bu+EGMU6AEL74w6Nv7jHsQJ1Enu9cPb3arBAj7RnY3YMwpcipkTJvIjFX4TFJlN0i8zIr/H3Oi9wnc7LY5qurcfS6NlsyFMeRd1APOlrkjNeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705558534; c=relaxed/simple; bh=gV4MiNQjlU4xhBTe+QyOd1xi2+bAtlmQaFvYtYZl7mE=; h=Message-ID:DKIM-Signature:Date:MIME-Version:Subject: Content-Language:To:Cc:References:X-Report-Abuse:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Migadu-Flow; b=S4ibLcbRHWZ16rrSB4cNKB/oT/wV50RiVSFRIkVFNPiMKxls9AVWm2mLw97NRGoQtwc9wKdhRP6/eOl/njqW+einbNhrCbf7vtdUiLFntI6jH92CHPaKhVAh67DRl9JFpHJItmovHc5h/k5YSn3L4islrRzFhqFDHVideSRAn78= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=cl5mJQEP; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <1cfdf574-90cf-4143-b735-7b8354098e6d@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705558529; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mh84LK5Hn0va2aqVidMrgA/rXrDauaZUcxawgJ4ahFA=; b=cl5mJQEPA++vhqUv/LLC7QCgcUrAvzl1ZcM+Sn103AGaw4YFEQEun6O6xNp8sEKn+iH8g9 /2B3OUr9EBe3onRV/M8tYnAmuzoaQekgIpPOO3Zih2yTAW7VOCGnFTjmoSDm4NxVLDY1mb lL5081W5/E+CY1VYrT/BcUV0cGGBFxs= Date: Thu, 18 Jan 2024 14:15:24 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v3 3/7] padata: dispatch works on different nodes Content-Language: en-US To: Tim Chen Cc: linux-mm@kvack.org, Andrew Morton , Mike Kravetz , David Rientjes , linux-kernel@vger.kernel.org, ligang.bdlg@bytedance.com, David Hildenbrand , Muchun Song , Gang Li References: <20240102131249.76622-1-gang.li@linux.dev> <20240102131249.76622-4-gang.li@linux.dev> <1d9074955618ea0b4b155701f7c1b8b18a43fa8d.camel@linux.intel.com> <1bd6ee64a600daad58866ce684b591d39879c470.camel@linux.intel.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Gang Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Hi Tim, On 2024/1/18 06:14, Tim Chen wrote: > On Mon, 2024-01-15 at 16:57 +0800, Gang Li wrote: >> How about: >> ``` >> nid = global_nid; >> list_for_each_entry(pw, &works, pw_list) >> if (job->numa_aware) { >> int old_node = nid; >> queue_work_node(nid, system_unbound_wq, &pw->pw_work); >> nid = next_node(nid, node_states[N_CPU]); >> cmpxchg(&global_nid, old_node, nid); >> } else >> queue_work(system_unbound_wq, &pw->pw_work); >> >> ``` >> My original idea was to have all tasks from a single padata_do_multithreaded distributed continuously across NUMA nodes. In that case, the task distribution would be predictable for a single padata_do_multithreaded call. > > I am thinking something like > > static volatile atomic_t last_used_nid; > > list_for_each_entry(pw, &works, pw_list) > if (job->numa_aware) { > int old_node = atomic_read(&last_used_nid); > > do { > nid = next_node_in(old_node, node_states[N_CPU]); > } while (!atomic_try_cmpxchg(&last_used_nid, &old_node, nid)); However, having the tasks from all parallel padata_do_multithreaded globally distributed across NUMA nodes is also fine by me. I don't have a strong preference. > queue_work_node(nid, system_unbound_wq, &pw->pw_work); > } else { > queue_work(system_unbound_wq, &pw->pw_work); > } > > Note that we need to use next_node_in so we'll wrap around the node mask. >