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 A1FC0C388F7 for ; Thu, 22 Oct 2020 12:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50DA02245F for ; Thu, 22 Oct 2020 12:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504566AbgJVMkE (ORCPT ); Thu, 22 Oct 2020 08:40:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:39384 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2442034AbgJVMkE (ORCPT ); Thu, 22 Oct 2020 08:40:04 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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