Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp58422rdg; Wed, 11 Oct 2023 21:09:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrv52XWoL5qZMknr1SsQAP19AKsLzC26jD8KUcItN9urALJ0ETk4Lmp0p/p3j68JIZYIr9 X-Received: by 2002:a17:90a:43e6:b0:27c:f282:adac with SMTP id r93-20020a17090a43e600b0027cf282adacmr9104661pjg.0.1697083777651; Wed, 11 Oct 2023 21:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697083777; cv=none; d=google.com; s=arc-20160816; b=p0ue7z5sEQ1pRFBMTtFmdUoda9p4v6BaRm2Mpm80IeEmGq+TwzafX3wK9AhzUEpjFT eL5fpykSwy524gLBElP76kwQfwx9mtEpKXlvRGr2uZpRc07f2Qk7AnaiPa/11YC+Wcy9 Vn0ueuBh4d0HzwB3/FCx1RC6LPZTqoVxU/2JLgDtwJq2AdjW9GmZtVetdceeXnU3BlBg /2mWpGqkXNand4AYqALWJ47vWyVjnbSXj74Fxt5qtmnrhcsJby8TNEKnfnDQ2ABrh7Kh w2L38lTfav8eFaaz+DAQEobKx1cNPP6rsgsvDrVPCMS1hJ2quJ21e80IK5L2hGEzMwE0 RtrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=t3eZtbO7sGiUdIhODmQ6vSPYTozABWE/uP0uElHmIZc=; fh=SgOfLQ2yICaLCKHh3NExUqZIjwPaTyuNrWGOMV98QNc=; b=o8Zwhlr6WzCcoBG1DvgiRxuOqJAYvhv6fqNdkTOm6Tq227CwItxaC4x8n7iHX5PQWY 1hJuSaYaMdOOf8uiKfobGjlXUVpsEGipFY4fm7Hpw0W/5DB+b3DzjzOubKM6cbqdBJz2 phhBbn1HLfvSCFb4kX1qsH8sGo/pLuYjbOt2JfW+xR8hg1VC/0Fp4ryfmhS2OWd97IpL 2u2+rcn3UBPgYKgFW24Y33GUo+oKHQTLrekkxYVpn3+Np+KRsnf+ZrhQL2Syez6SavFE veOr+NlIRIrgr8qIOfIPMlyHVr8yL2+zht4Q0i9f9C82BjpK3S4Xufyt70jxryHOGBme iY5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bwx9ODPN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c10-20020a631c4a000000b00563a0c1bf06si1204981pgm.428.2023.10.11.21.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 21:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=bwx9ODPN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1FFA18184AB6; Wed, 11 Oct 2023 21:09:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343517AbjJLEJZ (ORCPT + 99 others); Thu, 12 Oct 2023 00:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjJLEJX (ORCPT ); Thu, 12 Oct 2023 00:09:23 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE21B7 for ; Wed, 11 Oct 2023 21:09:21 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-d9ac3b4f42cso199826276.0 for ; Wed, 11 Oct 2023 21:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697083760; x=1697688560; darn=vger.kernel.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=t3eZtbO7sGiUdIhODmQ6vSPYTozABWE/uP0uElHmIZc=; b=bwx9ODPNNDPDbMUnIKhSU/DEB093iDQeKXp27IKtzl43IXu/mAsnQC0dA80jwugVfP KMYifPYmiH/F+tG0zXHqGb1VcpXtChnZyPJaG/DscPQRqtm7l5LVo40iMW+so2fxtkCp OQd34IFFOUYDYAdhDoo+jKgdrrRmk+0hKEoQqCaFmErRxiFg3eCwCyB0XyFal3eEICVX gy/ulDAgJp+T7QF1hpAMuxKtfYk6UhQq7YgqHEMsgfY4cEqJRsq0xz2KbiyN9HVjES17 NGlZzR5FR/nh2juQI2Xw/D57yHcy9kirq9UkgP05d4CRi1tT3LFsgpIbZwf+T5B8Wgv7 Sbhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697083760; x=1697688560; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t3eZtbO7sGiUdIhODmQ6vSPYTozABWE/uP0uElHmIZc=; b=E1wkYrPNkAMFRl/EV/IrLv7p1lLEmM+mt28ZGV4+JNecGOXW5hLsJnu04iTfAhvsVK fDZEL7QP4i1w4LLsh/8jvwY2auvdkmQE4zSzDYS7ZJjrODGeN0MLVSNEtIFUA+Jrjc0N cUcqb6AsugvbiKBsIcoh0/UzzvbzuTl0Fcv47HYo3QhDgmkL0ewnj1sdhQqaX8IsZIpI iWiV8pGx6UqB6glIym7oM/v/gVk6pQ4Pr0FZyPuHDLLw5sC/FzaKNJpISP3Cn+FsSD9j oOniG8vwvX1EslksafFYjH8tJs8Zp7LYhH2BTgIUOf0skpYePS+xIP16VlgT9bzwY9Az UJRA== X-Gm-Message-State: AOJu0Ywz5Pf+ktqI+zW22imcHunNfuoQXEP1e8lJMB//WMJ8li4uLH9n J+vgv3r6KTRr83M79jGizeTzgw== X-Received: by 2002:a25:8906:0:b0:d9a:b844:a16 with SMTP id e6-20020a258906000000b00d9ab8440a16mr859246ybl.16.1697083760445; Wed, 11 Oct 2023 21:09:20 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id r127-20020a254485000000b00d7360e0b240sm4936554yba.31.2023.10.11.21.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 21:09:19 -0700 (PDT) Date: Wed, 11 Oct 2023 21:09:06 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Dennis Zhou cc: Hugh Dickins , "Chen, Tim C" , Andrew Morton , Dave Chinner , "Darrick J. Wong" , Christian Brauner , Carlos Maiolino , Chuck Lever , Jan Kara , Matthew Wilcox , Johannes Weiner , Axel Rasmussen , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Subject: Re: [PATCH 8/8] shmem,percpu_counter: add _limited_add(fbc, limit, amount) In-Reply-To: Message-ID: References: <17877ef1-8aac-378b-94-af5afa2793ae@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 21:09:35 -0700 (PDT) On Fri, 6 Oct 2023, Dennis Zhou wrote: > > Sorry for the late chime in. I'm traveling right now. No problem at all, thanks for looking. > > I haven't been super happy lately with percpu_counter as it has had a > few corner cases such as the cpu_dying_mask fiasco which I thought we > fixed with a series from tglx [1]. If not I can resurrect it and pull > it. > > I feel like percpu_counter is deviating from its original intended > usecase which, from my perspective, was a thin wrapper around a percpu > variable. At this point we seem to be bolting onto percpu_counter > instead of giving it a clear focus for what it's supposed to do well. > I think I understand the use case, and ultimately it's kind of the > duality where I think it was xfs is using percpu_counters where it must > be > 0 for the value to make sense and there was a race condition with > cpu dying [2]. > > At this point, I think it's probably better to wholy think about the > lower bound and upper bound problem of percpu_counter wrt the # of > online cpus. > > Thanks, > Dennis > > [1] https://lore.kernel.org/lkml/20230414162755.281993820@linutronix.de/ > [2] https://lore.kernel.org/lkml/20230406015629.1804722-1-yebin@huaweicloud.com/ Thanks for the links. I can see that the current cpu_dying situation is not ideal, but don't see any need to get any deeper into that for percpu_counter_limited_add(): I did consider an update to remove its use of cpu_dying_mask, but that just seemed wrong - it should do the same as is currently done in __percpu_counter_sum(), then be updated along with that when cpu_dying is sorted, by tglx's series or otherwise. I don't think I agree with you about percpu_counter deviating from its original intended usecase; but I haven't studied the history to see what that initial usecase was. Whatever, we've had percpu_counter_add() and percpu_counter_compare() for many years, and percpu_counter_limited_add() is just an atomic combination of those: I don't see it as deviating at all. Hugh