Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp200657lqp; Wed, 22 May 2024 01:38:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2+EQ65YhHkybL/5gPrzTrBSY60/82kzKIQno9rjUrXPEsjx1MXj+0Jy/JA1vvsR2zeGO6p6c8+9G0XOkAugsV3ZlIy3N5bVD9ywPBqQ== X-Google-Smtp-Source: AGHT+IF6hf7LkYTQYkVOJrndklBO/vHZlyDLzrP928wPp70GJes5Huef33OuCBlATGppIzPrxyom X-Received: by 2002:ac2:5982:0:b0:51f:3b4d:b087 with SMTP id 2adb3069b0e04-526c1215b86mr923025e87.63.1716367131198; Wed, 22 May 2024 01:38:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716367131; cv=pass; d=google.com; s=arc-20160816; b=vTdOXUG4KPdP8d7e29rBywv8He8AB/z9FfeK+57T05qAc/CBtHqxSt2+QBdlPk7rk7 LSHOVUuaUKkwJdT9oVo8IZtM29Miyq+phO/kRP2FudJr4uzLBksmsQpeViJJFeO5yzug xPj3OBcxjRneZF9LiUNVSQUGiVFZsGPjbS4yk1S0vo1x8Dh1tPUcbX4PuKKfX0YG73L6 9LTkOfrOQDbcO9GcHFJpr5BC9cFgG/Ufvu/EziEOzu60D5ZiZtQ5KWTy017Q0dIEofel SgqC+IB0WKKK6igR1iGhoqzmkA6BmawSt4bzcsFVV/4vtSXeBVV+y+GGDIp0jVWIBwME DBrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=m+G67b4GxIThbEafe87WEoBwf+8+QKS2G2eyvZIlV5E=; fh=eYXpBYX2M+IZW7ucxJlKUJFtQoRjUKdJqpw2oaA8Q74=; b=SR4+4JAazmdyln/WV0in7eyO1vOEI7Ym0XC7EscaSrdt/OtYWislu/9/A1U+9y6X0y ysHmz/xbU/t9rWIP/tHUcBgfck1rORPyZ2C7RwulKrmwGEGM8m0CGysFY67nT+YlR/aO puhZ1fpfEsXLAxE3Ya4w6Up8WmGpHqYux51XHr/HU11ZjMYzsETleKC8wVzzNvM6bFJ6 OVduljxKd7MX9VNoDEb1d2K7lDDLh8X6kI8piOQJTiLIZeuxwXJtCP++qL5F4wcSAOVh hzz8G/Y0FNsko2uJIqdSkXFHeK3Eh71vH3rdBrqQgbNIfvZBVQfs56/i4UsEr4dNHiDq h77g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HcYERscd; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-185940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c2c285si1482717066b.947.2024.05.22.01.38.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 01:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HcYERscd; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-185940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D845E1F22705 for ; Wed, 22 May 2024 08:38:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84E147E78E; Wed, 22 May 2024 08:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HcYERscd" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 244F37FBA2 for ; Wed, 22 May 2024 08:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716367125; cv=none; b=WZ7QVkTiW3TWGkApU1uQ4u//EEkMRLXKd4nT1HF+jX+E1f1aOYL1tOk80mjbFApzxsVNq67EU3FFweQ4PIY5In1JsvQQXs+XKbFEDdLgqMMiHXot7Woa3DSJny6oGkzVRFr+kc6O/X6i2V7f/jpq1qtEgcueeL0lqDLdd6lcxKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716367125; c=relaxed/simple; bh=UUF1Xl3WF/inRUVbCOLgMd/fbD1vWfQB+LFC7jXVyy8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IFpB82fZztdklHWXV9nuEaVqrkuCk+H2SG4sC2n+QoJ7/fCPn6WXqleu1eBrdjh6a8T8h2LRrw/ezjV/BCqBMEbFnHt2Zcki0GPCeweZ4lTfBRHnwgGWqcV34P/ohSW8OB72Wx2+7Zbn/N2TDpXCLxOB7espCgxPrtM6EERiTQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HcYERscd; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-572f6c56cdaso11956a12.0 for ; Wed, 22 May 2024 01:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716367122; x=1716971922; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=m+G67b4GxIThbEafe87WEoBwf+8+QKS2G2eyvZIlV5E=; b=HcYERscdHmNwFiGCriBRIuSZu3R7fTkcZfYGgArgGupJaW15Hs55T5q3BYApokuC3F y9myIM50uMcGHo7W+8VjKbmAVcGOofKn3WqPBv1BU+VHVADhw74mO/fSSlcinAW0rWHh BpuIAq4E3FmpNxRe7WDV4IdBvAm281HybSwyOpvbXPcjE2ppiDGboNJ2CvEhvBrcj8ng hozjtqMTJvxeYTnsJlDSsT6OANXpA3WIxtUHb/9qqL1YB4MFnNuyWfduLi2nr5W/w/Pk OsxHh+YrTfbk8umyzztXZIGo5pX09v93VFK67xei3iUEfMhaXXPaC31S8iqrkAndcd4P Nf3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716367122; x=1716971922; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m+G67b4GxIThbEafe87WEoBwf+8+QKS2G2eyvZIlV5E=; b=KvVLHuf0beiinae48Ir14ZAGrN+wMfMDuWeVG9BJ2OiXBzZaJDmz8P+/1Czzifl5sy FoVblyG4I6ek9DinCdudRXgmUaRui/sDiRqwAReXmzKm2PAfdUHqeqjgLuCJVTARF360 gjPLi6VXwsB1i1+YfetBdOt381wNCLdg6JKtzkg93l4LcMidxGLD8FP6VCG90mfQU5D6 uRFzEcYDbnI+sKiff8v3YwdEYaRLkODmpi9e3vfwJj5IuH9RILH/0pnrU9FZ7sEi8OyF j7CnMLZqetaWbUXKMF+cWLSlKp5zR6IbP2F2GJedXVFe6ySCoKYALEjgwwSwEkR+pnJO Qu1w== X-Forwarded-Encrypted: i=1; AJvYcCUFZNmRGzDOLR4jR1IQUCbLghP2ZnbTCA/Vxy5sgxX2ATrRpLW84ZkPsjEh/XXMt9uf1Nnf04UyeRqkbUFBflm990dm8th99UhxULQM X-Gm-Message-State: AOJu0YygptOdEWyzK3Aw2DJSn7rEjmnZwwaLzj7DTAAm8LXEsj/Prly9 CUrXOuUeBsB+mgJge1gnwv0ufTfuAoAzZiJJ57JM1LB5MlOYvk12p4wtz/TZRw== X-Received: by 2002:a05:6402:2904:b0:578:33c0:f00e with SMTP id 4fb4d7f45d1cf-57833c0f3a4mr63801a12.0.1716367122156; Wed, 22 May 2024 01:38:42 -0700 (PDT) Received: from google.com (49.240.189.35.bc.googleusercontent.com. [35.189.240.49]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-354f1664c7dsm275885f8f.86.2024.05.22.01.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 01:38:41 -0700 (PDT) Date: Wed, 22 May 2024 08:38:37 +0000 From: Brendan Jackman To: Lance Yang Cc: David Hildenbrand , Oscar Salvador , Andrew Morton , Mike Rapoport , Michal Hocko , Anshuman Khandual , Vlastimil Babka , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm,memory_hotplug: {READ,WRITE}_ONCE unsynchronized zone data Message-ID: References: <20240521-mm-hotplug-sync-v1-0-6d53706c1ba8@google.com> <20240521-mm-hotplug-sync-v1-2-6d53706c1ba8@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Lance, thanks for taking a look. On Wed, May 22, 2024 at 12:25:30PM +0800, Lance Yang wrote: > Hi Brendan, > > On Tue, May 21, 2024 at 8:57 PM Brendan Jackman wrote: > > @@ -1077,7 +1081,7 @@ void adjust_present_page_count(struct page *page, struct memory_group *group, > > */ > > if (early_section(__pfn_to_section(page_to_pfn(page)))) > > zone->present_early_pages += nr_pages; > > - zone->present_pages += nr_pages; > > + WRITE_ONCE(zone->present_pages, zone->present_pages + nr_pages); > > I'm not sure that using the WRITE_ONCE() wrapper would prevent load tearing > on 'zone->present_pages', but it's probably just me overthinking it :) Hmm.. this isn't for load-tearing, it's for store-tearing. I have a feeling I might be missing your pont here though, can you elaborate? I have just noticed that the original "big bad optimizing compiler" article[1] only says store-tearing has been observed in the wild when the value being stored can be split into immediates (i.e. is constant). But it doesn't really seem wise to rely on that. From what I can tell from tools/memory-model/Documentation you are really out in the wild with unmarked accesses. [1] https://lwn.net/Articles/793253