Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp792982ima; Wed, 6 Feb 2019 08:25:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IYKmzVn1E6pUHA84hJnCpobhrEhxR9g0HptcsMH9gsJ5ZaH7KQPrAUcSHg1579dDKKaz4I7 X-Received: by 2002:a17:902:9305:: with SMTP id bc5mr11450798plb.86.1549470355645; Wed, 06 Feb 2019 08:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549470355; cv=none; d=google.com; s=arc-20160816; b=uoOmmHbL7yow84/Bep82+P6j3z+e+rcJActo7t//Z2OWl2FL13n+wPGMmnMrBQJOKw DefMFw6TKGRnSMReG+WWk02wlV58C9cihlPCMZFjWD3nrNsq3RHJtQRP8mS7k7fFX9eT bn327jCH0KDi/YUOrlag1aC3oEj00PBvwfCmY4KJESAAI7tUbYsjNhqurDAPPCISowCE nF5lWyQfVmQZzVGYAmIcLfjFlVxSPZ+f8q62Yn+G3M5tkqCfymweof+o4xg1+s9dT/Qf 5hv8PFWUbKqRN7UuSCTkY1n2kfnQWURKUVz0Wt6XT2K/C8BhfH9VHFKFMHS5ERhvDAk4 wNWA== 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=z3kxfnmBJF9JEeLTh2Qv9UfiGWUm5fMi+IhLoPJOxnc=; b=XIEZM/raT6snVA9QOTjc+FZKnlB+butPQprajqsIVxJXHMhzFv3jjZGQtx58p1izII CqOCkrxTvOFayC97dbuOEno46L3dODRqQ/T9V3gdv5yMCX6xuEZZFppc/lwkKEba9Yru R6Az2MqNJJUDL9m30b5y4Ng2I9cwxvvtLwngCL9/d2iX2tZXkEiR87YO2mL7A3ODoOyK govMIQyj5qj21BtOxkYSyw3zGuF1aB1KNjq7P1O+Ew2NubpJDmslvJFi+fge2YWE7Z/Y AyPOITGXNnsvGeWYBkffh1dFPsDZkJNjE+ohhCNxzxnbCP4eRtTA0G0tgZycSARg8H6i Y/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TOs44IFx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si6093817pgk.367.2019.02.06.08.25.39; Wed, 06 Feb 2019 08:25:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TOs44IFx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730935AbfBFQYF (ORCPT + 99 others); Wed, 6 Feb 2019 11:24:05 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:32889 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbfBFQYD (ORCPT ); Wed, 6 Feb 2019 11:24:03 -0500 Received: by mail-pf1-f193.google.com with SMTP id c123so3305094pfb.0; Wed, 06 Feb 2019 08:24:03 -0800 (PST) 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=z3kxfnmBJF9JEeLTh2Qv9UfiGWUm5fMi+IhLoPJOxnc=; b=TOs44IFxpDo8l3wywTdA3/xWWnWhN6UatDpaS2Q6+Ctt6VczwdlhJvcDxfNfoU4Qe+ fPN7h4BtM3N/nwFPwhtz7RX+vJjiarfjv3srCVD1ioPk54nTxrIviR2d0WYwZ2UbZzns 8RHkSe3jVDJuf5jKDl5EVK/cSt+c2onn65qGVwYnHUVWjTOVeIh/gmzSRw/8asjhx+qh Wtm9DcqopbqECAQKKjz2FMkQQcabxRugpgJvZsQuSjyoQ5RchXF+0XjrNqLB54qFu5TW FQAoQHT3WngGSERXsY5Xl2xUGuhnQPXOS/bs7r7dZzI382rEoCwlE/cpHOcINQKxSVXS frlg== 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=z3kxfnmBJF9JEeLTh2Qv9UfiGWUm5fMi+IhLoPJOxnc=; b=sI8/j1AeedOhMKy2eUGexAGu110UVNjek4tb0jyxaFIdiwnalb+grcd6NHxLTTBB3s UuWAAI2IxlZlSSZ02D6ygzse6vkxF/SiAqGFxRcTyfOFGUnAi+8F2eVB7kDCpNk2X/4j PCafYSVVoma07vVdpSySewWs9XDCEUP/BF7szyuk44z/lYp9kxHr97+1XZgeTqI8Qqd2 wTtOpWIZoEao1cbmBmM3JQcxGVUurWUThlZ5u6dWHy+cGo8UqpLSEqGyYg+Y4+17buo4 a8w5XgQMM6Mf8onBQufWRvZcqPxNk+e4jDJqug0JXlQtGs751bXhYiklxSLft0fqsp2r j+jw== X-Gm-Message-State: AHQUAuY95Dd9MqUEeQKmuJGJqXIv5qVRu91xmucJz2YQ25rv3uQH4u1C aVMQNNdS4tUDbFxidDW3DCNw3Biz X-Received: by 2002:a63:1766:: with SMTP id 38mr5413529pgx.299.1549470242559; Wed, 06 Feb 2019 08:24:02 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y9sm9374626pfi.74.2019.02.06.08.24.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 08:24:01 -0800 (PST) Date: Wed, 6 Feb 2019 08:23:59 -0800 From: Guenter Roeck To: Tetsuo Handa Cc: Rusty Russell , Chris Metcalf , linux-kernel , Tejun Heo , linux-mm , linux-arch Subject: Re: linux-next: tracebacks in workqueue.c/__flush_work() Message-ID: <20190206162359.GA30699@roeck-us.net> References: <72e7d782-85f2-b499-8614-9e3498106569@i-love.sakura.ne.jp> <87munc306z.fsf@rustcorp.com.au> <201902060631.x166V9J8014750@www262.sakura.ne.jp> <20190206143625.GA25998@roeck-us.net> 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 06, 2019 at 11:57:45PM +0900, Tetsuo Handa wrote: > On 2019/02/06 23:36, Guenter Roeck wrote: > > On Wed, Feb 06, 2019 at 03:31:09PM +0900, Tetsuo Handa wrote: > >> (Adding linux-arch ML.) > >> > >> Rusty Russell wrote: > >>> Tetsuo Handa writes: > >>>> (Adding Chris Metcalf and Rusty Russell.) > >>>> > >>>> If NR_CPUS == 1 due to CONFIG_SMP=n, for_each_cpu(cpu, &has_work) loop does not > >>>> evaluate "struct cpumask has_work" modified by cpumask_set_cpu(cpu, &has_work) at > >>>> previous for_each_online_cpu() loop. Guenter Roeck found a problem among three > >>>> commits listed below. > >>>> > >>>> Commit 5fbc461636c32efd ("mm: make lru_add_drain_all() selective") > >>>> expects that has_work is evaluated by for_each_cpu(). > >>>> > >>>> Commit 2d3854a37e8b767a ("cpumask: introduce new API, without changing anything") > >>>> assumes that for_each_cpu() does not need to evaluate has_work. > >>>> > >>>> Commit 4d43d395fed12463 ("workqueue: Try to catch flush_work() without INIT_WORK().") > >>>> expects that has_work is evaluated by for_each_cpu(). > >>>> > >>>> What should we do? Do we explicitly evaluate has_work if NR_CPUS == 1 ? > >>> > >>> No, fix the API to be least-surprise. Fix 2d3854a37e8b767a too. > >>> > >>> Doing anything else would be horrible, IMHO. > >>> > >> > >> Fixing 2d3854a37e8b767a might involve subtle changes. If we do > >> > > > > Why not fix the macros ? > > > > #define for_each_cpu(cpu, mask) \ > > for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) > > > > does not really make sense since it does not evaluate mask. > > > > #define for_each_cpu(cpu, mask) \ > > for ((cpu) = 0; (cpu) < 1 && cpumask_test_cpu((cpu), (mask)); (cpu)++) > > > > or something similar might do it. > > Fixing macros is fine, The problem is that "mask" becomes evaluated > which might be currently undefined or unassigned if CONFIG_SMP=n. > Evaluating "mask" generates expected behavior for lru_add_drain_all() > case. But there might be cases where evaluating "mask" generate > unexpected behavior/results. Interesting notion. I would have assumed that passing a parameter to a function or macro implies that this parameter may be used. This makes me wonder - what is the point of ", (mask)" in the current macros ? It doesn't make sense to me. Anyway, I agree that fixing the macro might result in some failures. However, I would argue that those failures would actually be bugs, hidden by the buggy macros. But of course that it just my opinion. Guenter