Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp887076rdb; Fri, 26 Jan 2024 14:08:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnz3kFPJedayfxzejuFdv2+clzWos+bJ7Zvgtgk/Mokq8nqGwesSjqjkH6q9BYETPrJ8ur X-Received: by 2002:ac2:428a:0:b0:510:250b:494d with SMTP id m10-20020ac2428a000000b00510250b494dmr216814lfh.0.1706306939597; Fri, 26 Jan 2024 14:08:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706306939; cv=pass; d=google.com; s=arc-20160816; b=Ycx2CRJxIVhDE93YN659yDeb/Dd3OhmV3HlZO/9WaWdwdJJYLkB+kB8etOKuI/DaXc 7c1flnT3S8YG4DnEPZqCFnMXbdcBxsCXUmGnLhjcpgd0QhRoWmO5DAwA0nd11hQT4zOO 8S3xpnpHvAIXsrIrkpSnm2MXzOAcnt1rgXGDpVC6yrXCt+JDzp9O0tqMPIEb1VL2DxOO LXo5fkYbuqcVL1wQzLFbcDChKsSf0a7Fh1ncTvuWXCn2XClQmtnFLNJSTG31Uq1UXlyt 0PK97SjHgyhtBUXty2cQH1ebH/Cf1GOFuz3gI1YBYdNS/YTXzCBIbGyTE0MwOoeUwcA4 Hu+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=6GSjdcoXRL5trov+iE2hoQky/bCBVVYnxpaGKh3qlLE=; fh=IQE7hsTnUb19I7x7JQRLJcuTlVCyoQwHRF2INfJ6HpU=; b=IgPQUNZC2syHAWfX8qwAQtdTCTxwYhV9TDNjrbsgE+3hq+eCXab9JD78bXfKL6ST9Z OKeGlEioq9ip2AlmHUYCFda4oPe5ik8nndDozPGiPTNt19y/Ret5fQ/PK1dPUrEphNZ3 VuGkPYGB6pGhIpMiw2ntpR8aIGoVDpwDGQkhM8pLI26Q2Jyhwoph3sDfA0/lRU8abP9X UGRNStzeNXA1fwyTvAMW1MZz8L1daWVvxRbySzhNdQrBl8MK4/eSENl8/4TTaAmDKaR3 BWRIrNII1ybxb08GdZZyCD0CdhRhCplhoQHabgUifV/nO2RGCcMfUtbJfGC5jPyvNSz+ 4SXQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hjvpsiEe; 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-40719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lo12-20020a170906fa0c00b00a3174a0b8b6si979318ejb.718.2024.01.26.14.08.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 14:08:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hjvpsiEe; 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-40719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40719-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2DC971F22E21 for ; Fri, 26 Jan 2024 22:08:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8490725564; Fri, 26 Jan 2024 22:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hjvpsiEe" 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 C38272555E for ; Fri, 26 Jan 2024 22:06:13 +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=1706306775; cv=none; b=HhMPfprMCAk9uH6peOyhqhBT5ucrcC7kNkUdpv+yJuU1rxtkOqi1MCdzefyM6q+xahxcqYFMU0sVrTkIPKrdmq3gaCc3+26gg6hXwR93mBhyympj5p+b0YuENBCAlysV4WGT7t0sLSDGG7Cf6OZZvhIoYHxh6/yxcQB60+bBzbU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706306775; c=relaxed/simple; bh=dCpJQu3vfIDAJ1Aq2AGyqLIgVqEbRZWCZQ8ESsL/WSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=bCGG4ghZlSBrmTgwqdXPz0b3TVz8CFrOQIqMFq1IKVKHGiRuYApzCvOcf4qn6JA7uW7QbbJ6rp3XOmHHAmv/O6Ik2qk4xXsc9avAr2rOleadtGlnxOKWdDU/rCNJMZNuoO4245DAlk+1hCJNiU51eAN6CX96vfC+bGYrLh3G4kg= 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=hjvpsiEe; 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=1706306772; 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=6GSjdcoXRL5trov+iE2hoQky/bCBVVYnxpaGKh3qlLE=; b=hjvpsiEeJ88pr+vkYhg2awtsP2Uh7SFaIEVzOazpaqUqnFKLUR8r5L0vpTTF2+jkcJrqiQ ofJkbsJr4UoC5VTUdoiFm49H29joBjH0F5BD28z+KTmZRmiYdWpPNXi3GD++go5BR9oWGg BRSWk1TeD9TDacYI/51wYVOcF9pBFmw= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-Y0XBGdtZPje1rwYm68gYaw-1; Fri, 26 Jan 2024 17:06:10 -0500 X-MC-Unique: Y0XBGdtZPje1rwYm68gYaw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-783c781aa5dso137058585a.0 for ; Fri, 26 Jan 2024 14:06:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706306770; x=1706911570; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6GSjdcoXRL5trov+iE2hoQky/bCBVVYnxpaGKh3qlLE=; b=N/H4Kuml3o+HyrZt2i0Yi1RoekA6UcBm8htsTI6SSY8K0GIaM5se/xh4SNmrNic+0D 85oLIiAxzxH6kzACx0I5V01QPPj5QUNHRYsCYfRKLzWyNl1KQfePta4GO/Uh32sQ0k36 m3u56PfulxGMCCRjt4NVI8sqt+NI1CSzSu9LLvEgiNYxmAWrbrIiUCfuN+9AFJtOW9lU VGuh67hJxBugudETMoIdfOP/lYg98yTTFZAvjwQ0D6JgBT0J6RdQMnhj6XB6YFbpWf6F SFI0QyQjjW/6pij+ZpBTg8yCqHgKza3emJtwnL6OTgFNK4bw9ajTOpkcNVlMwYboO+jy Irww== X-Gm-Message-State: AOJu0Yz8X00UIlSYHG3g4JnRvPUWH6qP3X4X7G/iAYaTlirotCHcPImB HxojrLMBKPRCWfQEJSnvyDyfsazPGLS0sOqABVnWKRd4IyBHeiMWf1jDsCAJCdZBA3P7F/k6CiC saEJ5J+QLHYtk/OTj3xdcF9/sbyEvaKnYa2fs0F1/mhsb1HeUoCw6dwK47m0nBeTw53UEQg== X-Received: by 2002:a05:620a:21c9:b0:783:bfad:6b7c with SMTP id h9-20020a05620a21c900b00783bfad6b7cmr470415qka.81.1706306770112; Fri, 26 Jan 2024 14:06:10 -0800 (PST) X-Received: by 2002:a05:620a:21c9:b0:783:bfad:6b7c with SMTP id h9-20020a05620a21c900b00783bfad6b7cmr470407qka.81.1706306769792; Fri, 26 Jan 2024 14:06:09 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:96a5:ba81:becc:80f3:6a79]) by smtp.gmail.com with ESMTPSA id b1-20020a05620a04e100b0078397efd1e3sm917750qkh.31.2024.01.26.14.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 14:06:09 -0800 (PST) From: Leonardo Bras To: Tejun Heo Cc: Leonardo Bras , Lai Jiangshan , Marcelo Tosatti , linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/1] wq: Avoid using isolated cpus' timers on unbounded queue_delayed_work Date: Fri, 26 Jan 2024 19:05:35 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240126010321.2550286-1-leobras@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 Content-Transfer-Encoding: 8bit On Fri, Jan 26, 2024 at 11:49:02AM -1000, Tejun Heo wrote: > Hello, > > On Thu, Jan 25, 2024 at 10:03:20PM -0300, Leonardo Bras wrote: > ... > > AS an optimization, if the current cpu is not isolated, use it's timer > ^ ^ > As its > > > instead of looking for another candidate. > > The sentence reads weird tho. It's always the same timer. We're deciding > which CPU to queue the timer on. > Hello, Thanks for pointing that out, I will improve it in the v2. > > @@ -1958,10 +1958,24 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, > > dwork->cpu = cpu; > > timer->expires = jiffies + delay; > > > > - if (unlikely(cpu != WORK_CPU_UNBOUND)) > > - add_timer_on(timer, cpu); > > - else > > - add_timer(timer); > > + if (likely(cpu == WORK_CPU_UNBOUND)) { > > + if (!housekeeping_enabled(HK_TYPE_TIMER)) { > > + /* Reuse the same timer */ > > This comment is confusing because it's always the same timer. Thanks, I will point out this being the last cpu used to handle the timer. > > > + add_timer(timer); > > + return; > > + } > > + > > + /* > > + * If the work is cpu-unbound, and cpu isolation is in place, > > + * only use timers from housekeeping cpus. > > + * If the current cpu is a housekeeping cpu, use it instead. > > + */ > > + cpu = smp_processor_id(); > > + if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER)) > > + cpu = housekeeping_any_cpu(HK_TYPE_TIMER); > > + } > > + > > + add_timer_on(timer, cpu); > > } > > I find the control flow a bit difficult to follow. It's not the end of the > world to have two add_timer_on() calls. Would something like the following > be easier to read? > > if (housekeeping_enabled(HK_TYPE_TIMER)) { > cpu = smp_processor_id(); > if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER)) > cpu = housekeeping_any_cpu(HK_TYPE_TIMER); > add_timer_on(timer, cpu); > } else { > if (likely(cpu == WORK_CPU_UNBOUND)) > add_timer(timer, cpu); > else > add_timer_on(timer, cpu); > } > > Thanks. I am not really against it, but for me it's kind of weird to have that many calls to add_timer_on() if we can avoid it. I would rather go with: ### if (unlikely(cpu != WORK_CPU_UNBOUND)) { add_timer_on(timer, cpu); return; } if (!housekeeping_enabled(HK_TYPE_TIMER)) { add_timer(timer); return; } cpu = smp_processor_id(); if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER)) cpu = housekeeping_any_cpu(HK_TYPE_TIMER); add_timer_on(timer, cpu); ### What do you think? Thanks, Leo > > -- > tejun >