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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3E6BC433EF for ; Fri, 12 Nov 2021 22:10:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BA7D61051 for ; Fri, 12 Nov 2021 22:10:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BA7D61051 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 85A446B0075; Fri, 12 Nov 2021 17:10:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 807256B0078; Fri, 12 Nov 2021 17:10:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 681346B007B; Fri, 12 Nov 2021 17:10:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 570616B0075 for ; Fri, 12 Nov 2021 17:10:05 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 096C97F913 for ; Fri, 12 Nov 2021 22:10:05 +0000 (UTC) X-FDA: 78801671928.26.0D3D208 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 795191931 for ; Fri, 12 Nov 2021 22:10:03 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id r5so3274004pgi.6 for ; Fri, 12 Nov 2021 14:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=+bozFN43PrqEka1VKkgOIC1UoclebicKs13R4GOJwok=; b=WXoQpxYlmhhTgeXv0qSaJwtCDnGqTaOY10gBK/CIHIwQFJzfH1ExH9eiYIvL4+c6jS gFdtZuDyOT0WF99w1wRB/NvH1EWnXmiDsS8YMurqdrCITG12RjH6nTkLTRa0jA8u4rjS 4i0oACa0x0Dwu3lahcvScaiLB1/B+rrBw0XzxObZNJ2VRwqN1+e8/qmWHMRelMyrZALZ cn4Cf2z9MDDYpI5KsVyOdncOs78xfEMqTaeLAGAFvpHQIq1l+cjEhs01845ctNZh057K 50s2zqu8dlLwoLynyevZJKR9xLape+/UOWCw7NPRuQo6Uyj4weVf7gURom25X9nUxQh4 TctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=+bozFN43PrqEka1VKkgOIC1UoclebicKs13R4GOJwok=; b=5EWCNdZwQ6qJwlePc0t97qoqXe4jxUpmHBEuPDsYv2KcU0Dy7JRLYKB7sY7lRc197K 0L5firivtUss4qtzyMz2W5z8a6jwt5qc+q04rVNCjDdNoO+vXRJ7NxK/0WxMGRGi+kQv UwklRS5LTLpkYBnMzARHckHCzbC18Gwwt1N5C4j5InRCexlFOPPXQMXdpV1rRsDvv8lR nVw5aJAyJPQsIHX7dtMPdury+VD6/6xsqtbE091ubzimleqE653iWNMjwQQeOGUmp+uK 1uKT9yhnMzIBPz1wmydIjEw4w/ZMNo+rRKUz9IY0geogm9ULNNfTIs0xvIlYYnbgTyee xtyA== X-Gm-Message-State: AOAM533CCYIYuDZhHHKxi4eLZgFJFEEo5kIuIiIjeLrqwhQNJy350Sah Xr0to+YoeIx/EzFF5u7HwSg= X-Google-Smtp-Source: ABdhPJwn7EA9/s9FsE1ducTwkSegvj17VeOOfJKJzPI+i8bU7/ByMwCn9mL00Q7W4kULjCIy2udbAQ== X-Received: by 2002:a63:9844:: with SMTP id l4mr12005262pgo.271.1636755002418; Fri, 12 Nov 2021 14:10:02 -0800 (PST) Received: from google.com ([2620:15c:211:201:15b2:87b5:9db5:273a]) by smtp.gmail.com with ESMTPSA id u9sm7454300pfi.23.2021.11.12.14.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 14:10:01 -0800 (PST) Date: Fri, 12 Nov 2021 14:10:00 -0800 From: Minchan Kim To: Sebastian Andrzej Siewior Cc: Andrew Morton , Sergey Senozhatsky , linux-mm , Thomas Gleixner Subject: Re: [PATCH 7/8] zsmalloc: replace per zpage lock with pool->migrate_lock Message-ID: References: <20211110185433.1981097-1-minchan@kernel.org> <20211110185433.1981097-8-minchan@kernel.org> <20211111090727.eq67hxfpux23dagd@linutronix.de> <20211112073157.bfdfo2dzur4c5oqn@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211112073157.bfdfo2dzur4c5oqn@linutronix.de> Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WXoQpxYl; spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 795191931 X-Stat-Signature: rdok9kmht4ogj9ot4pafqy8jeyyrkhng X-HE-Tag: 1636755003-388354 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Nov 12, 2021 at 08:31:57AM +0100, Sebastian Andrzej Siewior wrote= : > On 2021-11-11 15:11:34 [-0800], Minchan Kim wrote: > > > > @@ -2077,8 +2043,13 @@ static unsigned long __zs_compact(struct z= s_pool *pool, > > > > struct zspage *dst_zspage =3D NULL; > > > > unsigned long pages_freed =3D 0; > > > > =20 > > > > + /* protect the race between zpage migration and zs_free */ > > > > + write_lock(&pool->migrate_lock); > > > > + /* protect zpage allocation/free */ > > > > spin_lock(&class->lock); > > > > while ((src_zspage =3D isolate_zspage(class, true))) { > > > > + /* protect someone accessing the zspage(i.e., zs_map_object) *= / > > > > + migrate_write_lock(src_zspage); > > > > =20 > > > > if (!zs_can_compact(class)) > > > > break; > > > > @@ -2087,6 +2058,8 @@ static unsigned long __zs_compact(struct zs= _pool *pool, > > > > cc.s_page =3D get_first_page(src_zspage); > > > > =20 > > > > while ((dst_zspage =3D isolate_zspage(class, false))) { > > > > + migrate_write_lock_nested(dst_zspage); > > > > + > > > > cc.d_page =3D get_first_page(dst_zspage); > > > > /* > > > > * If there is no more space in dst_page, resched > > >=20 > > > Looking at the these two chunks, the page here comes from a list, y= ou > > > remove that page from that list and this ensures that you can't loc= k the > > > very same pages in reverse order as in: > > >=20 > > > migrate_write_lock(dst_zspage); > > > =E2=80=A6 > > > migrate_write_lock(src_zspage); > > >=20 > > > right? > >=20 > > Sure. >=20 > Out of curiosity: why do you need to lock it then if you grab it from > the list and there is no other reference to it? Is it because the page > might be referenced by other means but only by a reader? Yub, zs_map_object.