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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44C8EC433EF for ; Tue, 21 Jun 2022 09:31:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25E16B0072; Tue, 21 Jun 2022 05:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD6C36B0075; Tue, 21 Jun 2022 05:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9E518E0001; Tue, 21 Jun 2022 05:31:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ABE606B0072 for ; Tue, 21 Jun 2022 05:31:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E7D7232B86 for ; Tue, 21 Jun 2022 09:31:48 +0000 (UTC) X-FDA: 79601725896.09.70B0B86 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 6A71F40017 for ; Tue, 21 Jun 2022 09:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655803907; 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=yNJyBfhqP2psGpws40LdnX+6Y0ecy5tj++L02hDTNeg=; b=fL8IPF8XAUvMrY/LXe6UV1Y+nhkKD2rSoMZzMtdrVfrMRe5wVnndq7JiSMdzShDkH30YSx YqPshIrrUekqvfmGZGjGEGtxAf7cSDwRrZ8MZTJ9bWjFG3TkLXtR+VePZGOEqtszEQkhRC AczqeemeBekO8PnA4hpUvWuiVA+ioP4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-yS9kPFalMReqsWbfKWqibA-1; Tue, 21 Jun 2022 05:31:44 -0400 X-MC-Unique: yS9kPFalMReqsWbfKWqibA-1 Received: by mail-wm1-f69.google.com with SMTP id m23-20020a05600c3b1700b0039c6e3c169aso6139072wms.2 for ; Tue, 21 Jun 2022 02:31:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-transfer-encoding:user-agent:mime-version; bh=VGKFaQXI7Vycha22w6zMWNSh9b/P0DeKulo0BjmnruA=; b=Z+5DwUF0vkJYng7h7LAhaGDNHK8ooLACxBEw9LvH3bINXSFcUQJsQjjBAZQpykXyps oqSp/YKiIbXFP9xuPS6TUBgUpZtbYIgwc20MxYkEP1czbVXh7otBjF3SFwI59ysTvgea RW/4tGD2TnuIfRsDWy1/iatT40imDXsW5dGYLLEWgzrqgAF8HcSr7ROXZDxD+nA6+of4 qzbAI9+PenhxbpzhSuiOKe8WSRk+TzrmbZrjhjTBvIZoT1slyesj1kiNGlYELkpji6AC xiL5qbt2lr+560wAI5l0aeXeJsezWLDk5SynwTGr+PqUseymFDDk0740+kU8w7QTH0yo +Qwg== X-Gm-Message-State: AJIora/MbCSi37epSkD4MkKJTAC+qnKUUKTmRYdGrcSwrzgBlUCZa/l/ 2vH3A5d2DwiMbmq3QRxkLAQP2Gc8J56v4MuEM3080rYwUtS0AVxfGt5z7qqUMrf7Ex8FC8mBaiX MyVPxaxLEb44= X-Received: by 2002:a05:6000:54f:b0:21b:944c:c70b with SMTP id b15-20020a056000054f00b0021b944cc70bmr5442272wrf.572.1655803903284; Tue, 21 Jun 2022 02:31:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tNk/DJ9ls9t+jxPiliozBGhQQYVU2dBuA6MUNSG9KKPfxVZxCyIXT5RioZo+/fj+54bzhhIw== X-Received: by 2002:a05:6000:54f:b0:21b:944c:c70b with SMTP id b15-20020a056000054f00b0021b944cc70bmr5442255wrf.572.1655803903056; Tue, 21 Jun 2022 02:31:43 -0700 (PDT) Received: from ?IPv6:2a0c:5a80:1b12:b300:47b0:25ba:1a2e:72ac? ([2a0c:5a80:1b12:b300:47b0:25ba:1a2e:72ac]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c351400b00397342bcfb7sm19003908wmq.46.2022.06.21.02.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 02:31:42 -0700 (PDT) Message-ID: Subject: Re: [PATCH 7/7] mm/page_alloc: Replace local_lock with normal spinlock From: Nicolas Saenz Julienne To: Mel Gorman Cc: Andrew Morton , Marcelo Tosatti , Vlastimil Babka , Michal Hocko , Hugh Dickins , LKML , Linux-MM Date: Tue, 21 Jun 2022 11:31:41 +0200 In-Reply-To: <20220621092950.GF15453@techsingularity.net> References: <20220613125622.18628-1-mgorman@techsingularity.net> <20220613125622.18628-8-mgorman@techsingularity.net> <04709b2d0dc702c9bf50f57cde125b07cdf54363.camel@redhat.com> <20220621092950.GF15453@techsingularity.net> User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655803908; h=from:from:sender: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:dkim-signature; bh=yNJyBfhqP2psGpws40LdnX+6Y0ecy5tj++L02hDTNeg=; b=2j9SlszNWM0jNkEDH/+dIST6mhZNLjYOY8vYPHOnq8eKjPTV4krHWzYBXY3jg0vHYJm0Y+ g3iX3T93tMqr6HStUvetcNAFHUijh8BCOYDdZ4hIsHb8Rq4MspHQyXZ/uoGtphKRn6uPGw 1OyuBmGk2HN6jzCje4MFnmVuqBlCMxI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655803908; a=rsa-sha256; cv=none; b=v+lqNlmS98iKY/oFP8y5xfmU2oc6wxz35VmYRk/PIOrWg7cEBbiNWrwZFASBgKpEs/TE0x OshUWgOAQvD10jm7E2yG5cp9yd2RxIeNlw0Xq38DEn2RQ25SbKcm5whZDzX4uhu+j0GSA2 /+NFqybBNoyBRQw+n5L9eekaU8YBt8E= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fL8IPF8X; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=nsaenzju@redhat.com Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fL8IPF8X; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=nsaenzju@redhat.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: 5sitjn1ubwywdysu6japqyybe98nqyt8 X-Rspamd-Queue-Id: 6A71F40017 X-HE-Tag: 1655803908-921340 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 Tue, 2022-06-21 at 10:29 +0100, Mel Gorman wrote: > On Fri, Jun 17, 2022 at 11:39:03AM +0200, Nicolas Saenz Julienne wrote: > > Hi Mel, > >=20 > > On Mon, 2022-06-13 at 13:56 +0100, Mel Gorman wrote: > > > @@ -3446,12 +3490,16 @@ void free_unref_page(struct page *page, unsig= ned int order) > > > =09=09migratetype =3D MIGRATE_MOVABLE; > > > =09} > > > =20 > > > -=09local_lock_irqsave(&pagesets.lock, flags); > > > -=09freed_pcp =3D free_unref_page_commit(page, migratetype, order, fa= lse); > > > -=09local_unlock_irqrestore(&pagesets.lock, flags); > > > - > > > -=09if (unlikely(!freed_pcp)) > > > +=09zone =3D page_zone(page); > > > +=09pcp_trylock_prepare(UP_flags); > >=20 > > Now that you're calling the *_irqsave() family of function you can drop > > pcp_trylock_prepare/finish() > >=20 > > For the record in UP: > >=20 > > #define spin_trylock_irqsave(lock, flags) \ > > ({ \ > > =09local_irq_save(flags); \ > > =091; > > }) > >=20 >=20 > The missing patch that is deferred for a later release uses spin_trylock > so unless that is never merged because there is an unfixable flaw in it, > I'd prefer to leave the preparation in place. >=20 > > > +=09pcp =3D pcpu_spin_trylock_irqsave(struct per_cpu_pages, lock, zon= e->per_cpu_pageset, flags); > > > +=09if (pcp) { > > > +=09=09free_unref_page_commit(pcp, zone, page, migratetype, order); > > > +=09=09pcp_spin_unlock_irqrestore(pcp, flags); > > > +=09} else { > > > =09=09free_one_page(page_zone(page), page, pfn, order, migratetype, = FPI_NONE); > > > +=09} > > > +=09pcp_trylock_finish(UP_flags); > > > } > > > =20 > > > /* > >=20 > > As Vlastimil mentioned elsewhere, I also wonder if it makes sense to ju= st > > bypass patch #5. Especially as its intent isn't true anymore: > >=20 > > "As preparation for dealing with both of those problems, protect the li= sts > > with a spinlock. The IRQ-unsafe version of the lock is used because IR= Qs > > are already disabled by local_lock_irqsave. spin_trylock is used in > > preparation for a time when local_lock could be used instead of > > lock_lock_irqsave." > >=20 >=20 > It's still true, the patch just isn't included as I wanted them to be > separated by time so a bisection that points to it is "obvious" instead > of pointing at the whole series as being a potential problem. Understood, I jumped straight into the code and missed your comment in the cover letter. Thanks! --=20 Nicol=C3=A1s S=C3=A1enz