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 73C7EC636D7 for ; Tue, 21 Feb 2023 13:51:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87756B0071; Tue, 21 Feb 2023 08:51:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E37DF6B0072; Tue, 21 Feb 2023 08:51:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFEF46B0073; Tue, 21 Feb 2023 08:51:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C12C36B0071 for ; Tue, 21 Feb 2023 08:51:36 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6A8E9C0498 for ; Tue, 21 Feb 2023 13:51:36 +0000 (UTC) X-FDA: 80491436592.19.A5D5DD7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id C2871100013 for ; Tue, 21 Feb 2023 13:51:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bH66sA8f; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676987494; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NEdXprvhxHyHHSPQOtkKZLXBLzv1Cy2bQgCVUfMHYac=; b=UsyYb3o28c6+KQNkwu2rqD9ettehu9ccGSDSkI9wY1qouIHiLBs6FD0/mEpcGbzqTi+jbY 107k26LQnqoPZQkIqzZsdAfWfU/04zlLi/OE1RfX9k4sfAy/TFvQ0wYDZbZxQsa7RszqyK mTloX6kvsWQdDuuK61qNJbNfmFNZgP4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bH66sA8f; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676987494; a=rsa-sha256; cv=none; b=D8qdwvlJxdAWcsoC5Ur0miy/eFv1HjzsNiBQe3SO20Uf7nH9IeqiMHhfaCBiaQ3LCPuEbM g+zYJFd9mItxGRHcUr/Mlrsz5WvXUO1m/znQfghlawtYitH+LEpjvdpOabBLUCnfHTrXo9 oxB7Mm0HTKYgdIJZZUdqA9isBAeq8Ac= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=NEdXprvhxHyHHSPQOtkKZLXBLzv1Cy2bQgCVUfMHYac=; b=bH66sA8fhWiJwQgo9PIB7tMy5k CksVVbZTIHgCQSPNdPeVxN0HKxQ1+pV9FYrnABQ3mTEqaH7e1DRPYTwHZYBtSYyXZZWkl8y3Z68zq uQFaZrRSGbPJjxA/REMS6x8QUqcbMZ8qJeQKFzvwdyFT8wL5o/x2mhz5dHl2YFUDSnfQyymSPy8lx FAkT6yQ9vuZLtc5WTQoo3oTYkHeGORlrSkJhFeNKSLbHLDY9ayuIgtw7AEwx/Pb4/9QHd+lXRXmHn rVqTpfRYBenwXyzvbVqvMDx7Sk/DmvQdOJO+34bkSxQdt7ZAIvHFZ7eOl0ME9lDFuAn9uvJ+fpjNG 0W6/FiLw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUT3J-00CeYG-Ir; Tue, 21 Feb 2023 13:51:29 +0000 Date: Tue, 21 Feb 2023 13:51:29 +0000 From: Matthew Wilcox To: Shakeel Butt Cc: Roman Gushchin , Yue Zhao , linux-mm@kvack.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, muchun.song@linux.dev, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: change memcg->oom_group access with atomic operations Message-ID: References: <20230220230624.lkobqeagycx7bi7p@google.com> <6563189C-7765-4FFA-A8F2-A5CC4860A1EF@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C2871100013 X-Stat-Signature: 7cajsf7fkjtzf74nxzwtn4iwx4i936o8 X-Rspam-User: X-HE-Tag: 1676987494-480817 X-HE-Meta: U2FsdGVkX1/slI0DosYZz8XnBPv+ojoSh5B0Fxb5Q2UlX2f3Hqpik/Phzrb3QVmTDh9GnyxBi1NyHyRTn9l4Owhcq0GwYuou7QdDxFWFPdZc0N9vID2i9cMRGd+UNxPborLwSUgKAsr2IwqDP9Bv2LmBSjLO5O78zrFZWGAkETT0BNUSa/awfegs8Yax/jCnuJFYuKJoJgv+hcr26g93T/L6pR535WgUlwjCT6gfzUSdo8SQR+sIc+8BzCenq4eU3dMg1zT5lL6Fj/oeCnii1FKPpLBoFQhWnx45Zya3VEDKLQ8NrBxZ37nSN+BXmceAP4CezOcG2jfhFBqt9aa+6Lcw9yTbccwa4Ded3k1KZuOC+bQCaLhSb9HU7YL8GnyKhlxR5vX09FNNP4yNV4w7J/75chtS2dgFqCJ37rPbz7Oj6O/3qt5kcANJXyejH2pfZG1rOK+6FYme+RIvRaqnoCzGLE+eoe/WAyCifSpU+Sh0HUYRxMP3hKXg8g7ZERIOdnFlsvTIXMRGDqHSEAFVtF3eJklEy54rPmuv5jTsi4RJC6cQMaEmoBA3kefSGHkhojTw297xoJMXQ7fH4r/vshXjIPMSvqlyXS2NSI5XtS7DmG3qIsmPDE6l167F+bQHM9KVecIaeiYrJSQ/HHExoDRo59sjqEpuoJMXe6Ov11cbZ3Fvje5zjDnerL2EXl1PwdouuO4OCRALP3nsdWK4YwMOjyZhbe7SCldCobDFrb0P/GK502C++3wYxH2GE8Mx39iKXT6HWr0EwP/Y2aCjkU3SI/AyumpI2Z2BY98bTYtOcG7JtQO3kl98yOfkihFY9sQIW4Vz+RnCWxr8KenGMRO2MdkJ9/kkSiohXeL+BhovLit2aLR+0BzSa6UwSUApQSsSptDQyVt5j+lssanHdjx5g7T/3yk1wUphujQeJqsZFgkCJC23jDkvPzE/bD7AARxBFPf/rE6Buh0YbUP wZI3/dnp 8eCCoRuPYtJgCkXudtn5kxDuJYs9+PWDTJY1s1W+TSG1OnJca0pLd9fNXP1Y4m8/agJkbEN1CEogr4KZFJmvuYhM/b7kPyIESQjsQ0Err0dLzh0gbspd2q/pJ7CCH1U9sgEOCUs+QuJmqYOibeFjnDGIGbus6hVvCMO1PHYd+XnIL7P30hAy67vwBl/robbyACE2IllmDDg8xbzQgh40oifMRBIxaiwRYWKjmac9VKhhoD331iY3fY08PtA== 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 Mon, Feb 20, 2023 at 10:52:10PM -0800, Shakeel Butt wrote: > On Mon, Feb 20, 2023 at 9:17 PM Roman Gushchin wrote: > > > On Feb 20, 2023, at 3:06 PM, Shakeel Butt wrote: > > > > > > On Mon, Feb 20, 2023 at 01:09:44PM -0800, Roman Gushchin wrote: > > >>> On Mon, Feb 20, 2023 at 11:16:38PM +0800, Yue Zhao wrote: > > >>> The knob for cgroup v2 memory controller: memory.oom.group > > >>> will be read and written simultaneously by user space > > >>> programs, thus we'd better change memcg->oom_group access > > >>> with atomic operations to avoid concurrency problems. > > >>> > > >>> Signed-off-by: Yue Zhao > > >> > > >> Hi Yue! > > >> > > >> I'm curious, have any seen any real issues which your patch is solving? > > >> Can you, please, provide a bit more details. > > >> > > > > > > IMHO such details are not needed. oom_group is being accessed > > > concurrently and one of them can be a write access. At least > > > READ_ONCE/WRITE_ONCE is needed here. > > > > Needed for what? > > For this particular case, documenting such an access. Though I don't > think there are any architectures which may tear a one byte read/write > and merging/refetching is not an issue for this. Wouldn't a compiler be within its rights to implement a one byte store as: load-word modify-byte-in-word store-word and if this is a lockless store to a word which has an adjacent byte also being modified by another CPU, one of those CPUs can lose its store? And WRITE_ONCE would prevent the compiler from implementing the store in that way.