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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 F0703C433ED for ; Wed, 14 Apr 2021 07:32:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C1AA613E9 for ; Wed, 14 Apr 2021 07:32:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C1AA613E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gentwo.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D4B066B0072; Wed, 14 Apr 2021 03:32:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFB536B0073; Wed, 14 Apr 2021 03:32:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC2426B0074; Wed, 14 Apr 2021 03:32:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id A0BC56B0072 for ; Wed, 14 Apr 2021 03:32:55 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4B2FD181DB371 for ; Wed, 14 Apr 2021 07:32:55 +0000 (UTC) X-FDA: 78030155910.35.515EABB Received: from gentwo.de (vmi485042.contaboserver.net [161.97.139.209]) by imf17.hostedemail.com (Postfix) with ESMTP id 21C8B40002D0 for ; Wed, 14 Apr 2021 07:32:52 +0000 (UTC) Received: by gentwo.de (Postfix, from userid 1001) id 3932EB004EE; Wed, 14 Apr 2021 09:32:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id 368EAB003B4; Wed, 14 Apr 2021 09:32:52 +0200 (CEST) Date: Wed, 14 Apr 2021 09:32:52 +0200 (CEST) From: Christoph Lameter To: "Gong, Sishuai" cc: "penberg@kernel.org" , "rientjes@google.com" , "iamjoonsoo.kim@lge.com" , "akpm@linux-foundation.org" , "vbabka@suse.cz" , "linux-mm@kvack.org" Subject: Re: A racy reading spot on n->free_objects in slab.c In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 21C8B40002D0 X-Stat-Signature: 63eo8hud89n7wici7t9hjenhnq9byh8n X-Rspamd-Server: rspam02 Received-SPF: none (gentwo.de>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=gentwo.de; client-ip=161.97.139.209 X-HE-DKIM-Result: none/none X-HE-Tag: 1618385572-390173 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 13 Apr 2021, Gong, Sishuai wrote: > We found a racy reading spot on shared variable n->free_objects in > slab.c and it can be data-racing with several writers that update this > variable. As shown below, in function cache_alloc_refill(), > n->free_objects will be read without any protection. It could be > possible that the read value immediately becomes out-of-date when > another writer is changing it (e.g. free_block()) Ok that is fine. If we mistakenly fill up the per cpu cache with new objects to the slab then so be it. If we mistakenly take the lock and fail to get an object then we can still reverse that decision and do the other thing. Maybe we need to add a comment there?