Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2349426rbb; Tue, 27 Feb 2024 21:15:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU8Ub6IFfq7qeVoOqqPlu2FE41lraxvCzieB/ytRl+XnEqzC86n9QGchh4dLuohfmLrmB9ZpJ/jVZCAV9g1snccFAgXMgarxNXyQzbe1A== X-Google-Smtp-Source: AGHT+IH4Yx7j1oDLVppjYIPJaTFfvD+Bwlljsp3VVSutscNsbJsY5hdgS9L1RVLUWg1EKSwAw3FP X-Received: by 2002:a05:620a:136c:b0:787:f138:ac2e with SMTP id d12-20020a05620a136c00b00787f138ac2emr665307qkl.27.1709097346114; Tue, 27 Feb 2024 21:15:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709097346; cv=pass; d=google.com; s=arc-20160816; b=PBi24dQzpbgwyBTDVS/Cy+aKOlwBaTqYYg1QBcZRXKmrgFbCZ2gq4Q9J2Q5cuD8UmG dtx76WKJYM42FYp1sia5T4zDMG9veK2Vz/YQCFjgBRICYxw6X/Wt7U1tVfJlJFgejwir iNrHZoSmk9SrE5f4I2EkSF8Swqv6hmevaUPo8f0erz/QgKzAjEfcze9vtBJ3A7Ni8FoB pVeTFOyKkUTBrc8SvPVzwyLp6+xkiUoAFkDERA40KFpk+RxQQODmJc98vZKvwi94T0w9 0tEbKcm5FHlP4358CkGjP5HO1knCOuLX1Nz/OuQiF4ZabXLlF5JmqGUd4AAs8KiXanjB 8j8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=zgZMTdjfNWQh0YDiJwwEXmgUlMNBEeWeipdoEla6gn8=; fh=j/TWQbRLEym5V5clEZs5GQr00gASbHmJWOUWnkyqc20=; b=PhUxYzShgVu70LROGLY5pegTgJFPnilthPgfjvW+U+r9MSd1ZqCbZ+YXFBgLHYZ3Hy yx74BHCMP+LZsZuwINuKnq6WXOIMObcscA9DQgc7c3FN1FLY6FH6eSwYGyTsuufNgO/S kt9MtXzCdDUoJKZl8rji2O+R+CJrzx7b3t+IxiCpa7UfZUXR42qU1E9R5p3uSEePAc2H hMPv37N8tSalUjLmz2MOZKHXIaLmjB7f4RSHNJHYuGpzm5tKSDw6faT9R1+cYnLdpUqs RVvrR1QxH9hk0phIqkwBMEFeV2QSmgazgBPsYIqyHnPyuKuYpwliMhYTFQx/1widQbxP P3tg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=GHsy7BXO; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-84525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x9-20020ae9f809000000b00787cb303eccsi7317520qkh.223.2024.02.27.21.15.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 21:15:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=GHsy7BXO; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-84525-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 44A2E1C2311D for ; Wed, 28 Feb 2024 05:15:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6988F20DCE; Wed, 28 Feb 2024 05:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GHsy7BXO" Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A64C210E6 for ; Wed, 28 Feb 2024 05:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709097312; cv=none; b=CRodC+nHClV9veOCa4gTDDb/mPzCKqs4oo01lmNX2hB+ny5JPS1NwPoz5mbcaES3C5L0pTtlpC9Qc0eBpkJh1YohLT11OYxXf5opBPHeN/PYWUNLune1WE+RwU9Kp8EQHE1ecZNLorQ4GhG2Fi0KLLCHP6tdwaTZhJWa1L1sgeI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709097312; c=relaxed/simple; bh=xTYHHrp6U8NIVX2UfNBmMHdjqPaESoOeIwGsvQDZ4ms=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=A/+67JhQ2YU0AZSO1ogM1qmPrga5IeoRedW3JmYjAQ6wN6O3uLKPoABYA+aVV1xltziZfOvodKrcQqUGXp/xJ2AK9JIA4woOsT6D4o5Hddl3iC53kkQL5jlIrYHdlprEHa2ZgICw9SBuo9OZxyYMmhXIgPn4FLK1jXz9vdVBp8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GHsy7BXO; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <5a556476-05b2-483e-8875-eeb3e2a51151@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709097304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zgZMTdjfNWQh0YDiJwwEXmgUlMNBEeWeipdoEla6gn8=; b=GHsy7BXOca+egXV4CajBfaEUEScRqCFSkIt0tELiypa4eFBUjfK9sxpf6IjkETbBUG14mB JKS/dxFB+Q4w4mIbjNrGawSDzZgNUV+yEysExTYDOGK+jdxLy1fCEkEnU3DDQ4O1bGzBtx TusvMbLtZHyVNvKegnvNJkNsdg/F3I8= Date: Wed, 28 Feb 2024 13:14:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 1/2] mm/zsmalloc: don't hold locks of all pages when free_zspage() Content-Language: en-US To: Sergey Senozhatsky , Chengming Zhou Cc: yosryahmed@google.com, hannes@cmpxchg.org, nphamcs@gmail.com, Andrew Morton , Minchan Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20240226-zsmalloc-zspage-rcu-v1-0-456b0ef1a89d@bytedance.com> <20240226-zsmalloc-zspage-rcu-v1-1-456b0ef1a89d@bytedance.com> <20240228043358.GF11972@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <20240228043358.GF11972@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/2/28 12:33, Sergey Senozhatsky wrote: > On (24/02/27 03:02), Chengming Zhou wrote: > [..] >> @@ -978,10 +974,11 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, >> pages[i] = page; >> } >> >> - create_page_chain(class, zspage, pages); >> init_zspage(class, zspage); >> zspage->pool = pool; >> zspage->class = class->index; >> + /* RCU set_zspage() after zspage initialized. */ >> + create_page_chain(class, zspage, pages); > > So this hasn't been tested, has it? I have tested it in my test vm, but it hasn't KASAN enabled. I tested the kernel build in tmpfs with zswap enabled using zsmalloc pool, not sure why the kernel didn't crash then... > > init_zspage() does not like to be invoked before create_page_chain(), > because we haven't setup required pointers yet. You're right, I can reproduce the problem with KASAN enabled this time, create_page_chain() should be put before init_zspage(), which will iterate over the pages to create free objects list. > > So when init_zspage() calls get_first_page() it gets NULL zspage->first_page > which we then use in is_first_page(first_page)->PagePrivate(page). As far as > I can tell. Thanks! I will fix it and test throughly before send an update.