From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E75C6CDB46E for ; Thu, 12 Oct 2023 04:09:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C10708D0105; Thu, 12 Oct 2023 00:09:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC0108D0002; Thu, 12 Oct 2023 00:09:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A87678D0105; Thu, 12 Oct 2023 00:09:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 95EDB8D0002 for ; Thu, 12 Oct 2023 00:09:24 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 56DD712043E for ; Thu, 12 Oct 2023 04:09:24 +0000 (UTC) X-FDA: 81335479848.27.D3B0EE6 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by imf14.hostedemail.com (Postfix) with ESMTP id 7BB9A10001B for ; Thu, 12 Oct 2023 04:09:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vf3XTyB+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697083761; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t3eZtbO7sGiUdIhODmQ6vSPYTozABWE/uP0uElHmIZc=; b=RWyZxdpvlVbD5xRVJ2NbBT7ictx1JUf6UNueQuJ4tp/8KmBIj8zdJSM50aisXWFMQkuUVL B+T7cigMBdTK5/ADYBjmxVSnWdPvqcxeBsYKGUY0KiBlncGms9/x1y+ZLBmt7do1KqFTyp xZvabcnhtTnKAUrfXzmc/JeLwOgCDYw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=vf3XTyB+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697083761; a=rsa-sha256; cv=none; b=aQYGyA0lPuhlUYf2KAgOsfM5VszJacWQyqgjADU6e1JUQDAwGSqboCbewmt9A6BXRChzjE Mpt74gVWvFKd3RaA+k0SkmTLFcvaUn8SONVfQwlL2MxrQs8ylRmW8jQ/ldpZyzZP9nh30c FiYMbfDaQfvSc+RRWp9nnakZtqSmfUM= Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-d9a6399cf78so443609276.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=kvack.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=vf3XTyB+4Hhyn3clz/GMJAQLHzmyVSbs6mharo6pnNf6yMPDCBZlLlHalviL1bz/zz 8EYKBEZ/70bz6TcMK2mXQoAA8vVpZEhE1teZig88VezyT623ErBgvG0GZEarx7D0HuCU 6pGR4RGaIi3Wu6LG7+G0UZkDbwzsub3O0cDuwbiHzAlPtKlC0hj5cRG7Qbw6Djem/Efj kgPVaqqp44IUeDhX94z/fXRwd5BAH+VH9PlZ9u5pNqd8Y8hMKWp+IOGaR7iiXWrwy9Fe 1ut1EudbP8DMNJCLzlGZnX4xU9mDE3cKV1BdO9QOgD4zNgBfwfucR0y/i/Q8EttUxOgI uC1A== 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=kS3d70rcbX0p2UOLVnfMsDNIy3Ts37HbIAV3fQI+gnhWvwLyFWQj8YYl/N8q7M9mO/ zOzic5QLQH+q9Ewe0aGvXEBZjzcEZVj3m5743IR2ftCTFc9E64yk5MoEEuUFC4YPi+FR ujRTh3A7zVo+DNZcbxOrwOQ3RRuoF+64c9ZibRbfVsV0sxP3C9go9F2KoZCOZhZp6grZ kRLKYuDjX7qG9CqyMHhyu9j+LwymJaRdyubFez8SbEZt+f+F6B7AgDWFGRb6wf/y2xgT PVRf6pce/3QQfyGdm2wcWwg8mZPVF7abdTwnzE6bBaZl9CRLmL1TZ17h+wHEHODafy25 j0wA== X-Gm-Message-State: AOJu0YxndjzybgBYvbv2/EhZIxILn+iVXtrwOTlfGDbjj/PEFe8Cbk3W g7jtJOTbT3qJCkglYi42706YrQ== X-Google-Smtp-Source: AGHT+IGBjSt9U3Lcb7U+xPW4tDBHFN+LRgiJXQXfyU6HuAimlavU+lytPlZrRXik3VKiQGg74BAbxA== 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-Rspamd-Queue-Id: 7BB9A10001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1a7uzwadxyhkmikg39e88cnn533rtjje X-HE-Tag: 1697083761-879669 X-HE-Meta: U2FsdGVkX1/AE3M0RHGFwHg+i1jSzha9tRq45BfzjjJGUMa9Heg/OFLQyrBsQ4tXctvnmHR5qBlVpCYGD0xi+Ah8xsi6Pkl70+8NIrgBPCFYvJm6C7+X3KCvHL7V95bRtGd+Kb8h60XfeJP2Xz+oXwZ8NdnrTiKIQrHteQ5t4fQWIqehCITrWabLv2RaA5RJRGy1/ih+s5STRujSB+/FdkiM9eYYx9ZoESBJlKbgLS/3KNiCRJsMEh22QojLmWLTbcItwlzNzmq7onwAit+o89PCYbNhbOUJLJmnfbBXwueY/sknxhTeU0/9Ta/hlr2WojV15kJhHZQTEojoPTuc9tPhCzEhzylb9E7HwPgYdwND9WrcaPWPZReJVSg0CpI2DDLblTKrdnkvY6q0qLYsAMhGXuCh7jIMfi0D53P3jS8JHhduB9KA0PrMw36gKjx4el84vSTC4+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vRRc4E+wmDow+Y2++oA5JIqVqNnNc23h6G X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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