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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99AF8C388F9 for ; Thu, 22 Oct 2020 12:40:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22EF3223BF for ; Thu, 22 Oct 2020 12:40:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22EF3223BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E8BE6B0068; Thu, 22 Oct 2020 08:40:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 571BC6B006C; Thu, 22 Oct 2020 08:40:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4394F6B006E; Thu, 22 Oct 2020 08:40:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 0C1106B0068 for ; Thu, 22 Oct 2020 08:40:05 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 797AD1EE6 for ; Thu, 22 Oct 2020 12:40:05 +0000 (UTC) X-FDA: 77399518770.17.river36_141609627251 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 5BB2F180D0180 for ; Thu, 22 Oct 2020 12:40:05 +0000 (UTC) X-HE-Tag: river36_141609627251 X-Filterd-Recvd-Size: 2527 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 22 Oct 2020 12:40:04 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1548FB934; Thu, 22 Oct 2020 12:40:03 +0000 (UTC) Date: Thu, 22 Oct 2020 14:39:58 +0200 From: Oscar Salvador To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Pavel Tatashin , David Hildenbrand , Joonsoo Kim , Michal Hocko Subject: Re: [PATCH v2 4/7] mm, page_alloc: simplify pageset_update() Message-ID: <20201022123958.GB26121@linux> References: <20201008114201.18824-1-vbabka@suse.cz> <20201008114201.18824-5-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201008114201.18824-5-vbabka@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Thu, Oct 08, 2020 at 01:41:58PM +0200, Vlastimil Babka wrote: > pageset_update() attempts to update pcplist's high and batch values in a way > that readers don't observe batch > high. It uses smp_wmb() to order the updates > in a way to achieve this. However, without proper pairing read barriers in > readers this guarantee doesn't hold, and there are no such barriers in > e.g. free_unref_page_commit(). > > Commit 88e8ac11d2ea ("mm, page_alloc: fix core hung in free_pcppages_bulk()") > already showed this is problematic, and solved this by ultimately only trusing > pcp->count of the current cpu with interrupts disabled. > > The update dance with unpaired write barriers thus makes no sense. Replace > them with plain WRITE_ONCE to prevent store tearing, and document that the > values can change asynchronously and should not be trusted for correctness. > > All current readers appear to be OK after 88e8ac11d2ea. Convert them to > READ_ONCE to prevent unnecessary read tearing, but mainly to alert anybody > making future changes to the code that special care is needed. > > Signed-off-by: Vlastimil Babka > Acked-by: David Hildenbrand > Acked-by: Michal Hocko Yeah, I never got my head around those smp_wmb() Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3