Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp14831rdh; Wed, 25 Oct 2023 14:35:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoz6y0RJyQ69OzAxkFt5ul0IChQXsVnpza4ooSuMxgGAIwa68ajmyozzBprJsEuEBnogPk X-Received: by 2002:a25:250:0:b0:d9c:147c:2883 with SMTP id 77-20020a250250000000b00d9c147c2883mr13838247ybc.43.1698269759461; Wed, 25 Oct 2023 14:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698269759; cv=none; d=google.com; s=arc-20160816; b=hDkCHksMT+52aiOvNGgNqFhfonF5+JWq1+lrf9k90Uq/0A5m6gXwRoAS5quFqw8wqx Yr+IzC0035xEelw46E1Wwub3LIhG9yUjNrsumXc4odPdtFV85mT/2LIGGnbr1CzdZ4xX Mc/tXdaxfNwrgm8YGWzrVxQ0V4NwTtgSDPOY0d0IGeQrTV8NFz50vXkLDfF9AbdamXJS krJL85QGPRaVrjjK1TMTd9OH9k6x9f1ssLLuhw2WszrLFqLEYm5fo3jk0RdP42+Xw0y4 MDHv4mOpr9dyr8NYdZcFY49aG0Vit7lGEbh8r3XbNmh+rfn5zE7E3gNoKj/2avSL7BKm A/Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=nsQUs9HpmqqONjSFfSfNK05Cw8v+f+5EPyvVkDrlURM=; fh=HWu1+x/a+KpUXW4S1hvM2b5+OIK45X5AMOvmrg3EdzY=; b=lUZceGVJWoVju2sQguYC5VXl/iHbwzYBE4Wp5YhlpbF0WhIcp1TBRKf24DyhLiQqd7 GyIhJFWUwsFK9KUv54eHY49Lsn0BOfhcJOVYGu5iMiRSezTmHDXdg3oH6MmOpDualckR nlgzxE4Fh8vJI1ELwgSotw6dzh04xM3s37GMiLz/TRplNOyDxecANFV38NCjqCDkkQcR lduu9YgRcUtYCAz5MsxRr1uorU+DWnToq6DT2689ZlYVgRzrDzfhZZUn5hDqVFEnSavw Hp+kClMPcoUJwNaw+qONCWG3bQgUeFpGBqP6wtqMb5be6iqErVnrPQ4G6wrKh8noLdON CgtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=gvc31YCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d190-20020a2568c7000000b00da06fb44e7esi3276943ybc.458.2023.10.25.14.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 14:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=gvc31YCp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D6C8E80CBF1B; Wed, 25 Oct 2023 14:35:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbjJYVfp (ORCPT + 99 others); Wed, 25 Oct 2023 17:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjJYVfo (ORCPT ); Wed, 25 Oct 2023 17:35:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A83D132 for ; Wed, 25 Oct 2023 14:35:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEE8FC433C8; Wed, 25 Oct 2023 21:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1698269742; bh=IS28A/VyLk5I38SKgMfcQn09iILXb887HXHzcLznG8g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gvc31YCpv+Y7y0YjUqk94gbhBtUUU0P1IMbjAwMKx6kH8R/tWBMgC+N4v3FSdU2sv 9x94CASS+zC889ij66qaaceSvGl7tDRXGSUEfEiu9QknBLeB08+2AUo46wlN2I/q2P FpKJIh/hiRpGDm//nPazoePJ4cqxZ5bb57RftGCs= Date: Wed, 25 Oct 2023 14:35:41 -0700 From: Andrew Morton To: Charan Teja Kalla Cc: Pavan Kondeti , , , , , , , , Subject: Re: [PATCH] mm/sparsemem: fix race in accessing memory_section->usage Message-Id: <20231025143541.e7cf114239b84105711a5f70@linux-foundation.org> In-Reply-To: References: <1697202267-23600-1-git-send-email-quic_charante@quicinc.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 25 Oct 2023 14:35:53 -0700 (PDT) On Tue, 17 Oct 2023 19:40:15 +0530 Charan Teja Kalla wrote: > >> * was allocated during boot. > >> */ > >> if (!PageReserved(virt_to_page(ms->usage))) { > >> + synchronize_rcu(); > >> kfree(ms->usage); > >> ms->usage = NULL; > >> } > > If we add NULL checks around ms->usage, this becomes > > > > tmp = rcu_replace_pointer(ms->usage, NULL, hotplug_locked()); > > syncrhonize_rcu(); > > kfree(tmp); > Per David input, I am working on using kfree_rcu(). How's it coming along? Given that we're at 6.6-rc7 and given that this issue is causing daily crashes in your device farm, I'm thinking that we use the current version of your patch for 6.6 and for -stable. We can look at the kfree_rcu() optimization for later kernel releases?