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 5A5FEC27C7A for ; Thu, 17 Aug 2023 07:51:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9ED9D280037; Thu, 17 Aug 2023 03:51:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 99D54280036; Thu, 17 Aug 2023 03:51:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8675C280037; Thu, 17 Aug 2023 03:51:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7721D280036 for ; Thu, 17 Aug 2023 03:51:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 39600C0F4F for ; Thu, 17 Aug 2023 07:51:40 +0000 (UTC) X-FDA: 81132827160.22.41BE189 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id EDB26C0018 for ; Thu, 17 Aug 2023 07:51:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IoEa8QSL; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692258697; 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=7MP/7o3FaNNZ8imM4/UJCiG/7I2yggfeAT20G2LmE6Q=; b=SkuX91UFPGcPrTzyGa4M21t9eA/lRLCJy0JQNLKhr71NzKOvqD7+RIevUCI5CUqPlgaoVw qxGznlQJFylH8p464IasBBr343szWnuw4hr9KFHO3Nsi3x5XzhjDu9QizKE3CxbePZ5JLB 3MrcrJ6RasS9N3W38BKqqGJSKsszY2Q= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IoEa8QSL; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of chrisl@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692258697; a=rsa-sha256; cv=none; b=T9EseqeAdlT4jr+mPqe/474roq+V7Rn5O50EXHQz4iVkBzWlsT12TP7z8LKcOn4u7ODDl7 09IAbfWi6oQS3ACqjOso3F0mH/ggwM0DFJzUr9z0k+r6kzj+Gbz2SCNrLm8dhWlSg7YMKS HVHav7wEc2gOJFS2KNiOIlH8nPpK63c= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EFCA263467 for ; Thu, 17 Aug 2023 07:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 636F8C433CB for ; Thu, 17 Aug 2023 07:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692258695; bh=7bSUwHmNO8dW3AGCI9qBWJ06AyfFTVir+EtSZOlGnk4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IoEa8QSLtA20a6gY/atDS1VQTjI/HQqhOWLgnzVn9CEqh8WVXOTC4anbLcJsc72gm 6kimXzkB6UdtyTiX2KblPdETkxQ+3gaIg22KZlWPM2nI9PBluWhyuUs5L/XFwDFnSZ FqIiMhEw/RwbHSRt5D5Z4StwjuSin9+JJp47iVw54qd+pLQ70gJNT65wEOs6cvMkZL HvTWxgXPNd9P6yDl37SPLLiQbywHpGaMUF+eWnXa3DHByI2HArj1DZS0LbBUjEUlZN d0nFGD3Xkh3M5WbESCMQeX/MFuw9uAjUVQOlLXVFDwFBtHXAs2lJLlpgqE2kXZsOmc IDUB4mVcEkkaw== Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-565e6502dbbso1622719a12.1 for ; Thu, 17 Aug 2023 00:51:35 -0700 (PDT) X-Gm-Message-State: AOJu0YyJa+YAJ3UKnHWpWXB9XDZRbmvoOQQxpUN6nTK0yZUDF8WPKeFE G71bt51d52ScmhNUxmILy3LBcvhRMKLPSazA+NLQgA== X-Google-Smtp-Source: AGHT+IFiAzBL8cK9fAiv09ewrCX1IoiXfSJ8wR0PjemT8qnHGFCuysHEWXc4VvJw6AUUU6kSNsUVCoOqgL262n41ckY= X-Received: by 2002:a17:90b:fcf:b0:269:7eea:d7f6 with SMTP id gd15-20020a17090b0fcf00b002697eead7f6mr2886423pjb.49.1692258694794; Thu, 17 Aug 2023 00:51:34 -0700 (PDT) MIME-Version: 1.0 References: <20230809100754.3094517-1-shikemeng@huaweicloud.com> <20230809100754.3094517-2-shikemeng@huaweicloud.com> <53956bbf-844c-97da-2057-a8805360b35f@huaweicloud.com> In-Reply-To: <53956bbf-844c-97da-2057-a8805360b35f@huaweicloud.com> From: Chris Li Date: Thu, 17 Aug 2023 00:51:23 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] mm/page_alloc: remove track of active PCP lists range in bulk free To: Kemeng Shi Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com, willy@infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EDB26C0018 X-Stat-Signature: 5tjgqhrwj9j4ebhz6dha85qzwohajfxe X-HE-Tag: 1692258696-48852 X-HE-Meta: U2FsdGVkX18Ds2nU942TfEI8FVQOcfmoNj7YXdLYy7/ujuS/eOTBcq/b8HKOpW7+o2uwgzd3/0GR2u+eLBbzS4bQax7/VW0EMTaFqoTzdzIY5EdkDJ1kgqRFCuTQP7SgGQB1fn70ibzozv2yYajY5D9qOWUWKGLDgeUgF/Fppk2LD9EwMcRqkpIPIGYk2ZfsxqnbaMMVgjen1aEXTOwdNMteGn0jkCvldIn11Psh9qOBh+869cx8/QNvWoQY0Egvkpke03O1iMshvQ8gzfY9C3J67kHeNcoxiG4Z4EOkmsAddEPKPrTbmkO03+o+qzFh8R8Rv37N3oxwp+xMyYKcME1aBinAiRvHXVqhCzolBKVcPUBdfA40+v7PX7BlGGnEFaEOQvCfeEoR4v1OQKcZG2F9arxruU1BKf84XoMZ9Dwlej/UwTedxHJDsjJLUU7VZ4iBDySCr8mJbhPFpDbbEsMLMiX92OPKtfzKxOWqJaa+FFUAxerfxlNA52N0GU7aEByuqHmQzkSk2uWrXql/rmlIwPlKMaUNctloY0S6wOyeV+xLwoMMk0lQ0SVR6FlClVK7EZmPdc+KOSdIohB6G7GVv8vMUizxkPuzEOJfwjIJH/uIH5jQk/i2TBXzbogNNOzMI7lfacvF7CCLiXuN1KQrG8d8gp9C5zxaTA/oSTdDgTQAVjgWaQpb+4j3GzmZxBU6EQu8l/cfRl4JbADAsNdP/ycBuNOIVg2yZ9c8r9dcWi4ll0cJ6N26xd20R8qWt8sJRcquShkG3M8gaKqs+1Dx4ZFS++w4TG+r/eh/OKQEPt19+jPJQQpEwo064dMWQjNiCWqCh0PHJasNuOkgULmdGCGYTcTK2iRyX5OHab+9KIu9zSa2GR0Cn4v5uyED2BJViw6hFiS0HuO86+73kKJ0nuJ5/PAunRILyClMI4NCJhnIcoosFPM7FbODjBkQZHFQ/it/93XzLhyfa04 acWjCS1f o6pXpaIIafd+VThn4oY4keExe4dcf4fmbnY5kFctJ9VyRRYiqJb/g0M4fS1Nyq8/XNUGV5KTvT+C/jMpi3kOpE6PA4ixgGzzjDcLzmxdrtK+9TPtM2QLWWU53nO2UJnnrfd4TgCYECMpe0ExhEquNdLegZyL82Nb/ukkCsaB5UXsTfefg1FS4xH1CcAHaDulz02r9TEZSLdMEaasZFbiaBTxRzVJqg+U/ssXEddGOg7wbETDyupRJ4u8zdtCPkYuyywxLdTb/BLaH6lTkZ4YUuvSVk2XLfvDBashtKkMD7G+SusDZMdMSkL4Ixgu/HskbhyEZp8kYHI6Wf14OhpSPu79pIarFx23R9oKV1QDEovs4nU3JcUtAZlcszfG9be0VNEhJgCj7QqT9cFhlIA3VspWJUKeuN0E/hAtZ6QueZo2zqm4= 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: Hi Kemeng, On Wed, Aug 16, 2023 at 7:22=E2=80=AFPM Kemeng Shi wrote: > Hi Chris, there is no functional change intended in this patch. As > I menthioned in changelog, there is no wrap for list iteration, so > that the active PCP lists range will never be used. > > I have a patch sitting in my tree for a while related to this > > count vs pcp->count. The BPF function hook can potentially change > > pcp->count and make count out of sync with pcp->count which causes > > a dead loop. In this case the BPF allocates a page inside spin_lock. The "pcp->count" is smaller than "count". The loop condition only checks "count > 0" but all pcp->lists pages have been free. pcp->count is 0 but "count" is 1. After a few times wrap around, the pindex_max is smaller than pindex_min, then reach to -1 cause the invalid page fault. > I guess pcp->count is set to bigger than it should be. In this case, > we will keep trying get pages while all pages in pcp list were taken > off already and dead lock will happen. In this case, dead looo will > happen with or without this patch as the root cause is that we try > to get pages more than pcp list owns.> Maybe I can send my out alone side= with yours for discussion? My patch is split into two parts, the first patch is a functional change to allow pcp->count drop below "count". The other patch is just to clean up, and should have the same function. Sure will send it out and CC you for discussion. > > I don't mind my patch combined with yours. > > > Either way is acceptable to me, just feel free to choose one you like > and I'd like to see if more we could do to this. Thanks Chris