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 C7D2EEE49A5 for ; Tue, 22 Aug 2023 21:46:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5348D28004E; Tue, 22 Aug 2023 17:46:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E459940007; Tue, 22 Aug 2023 17:46:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AC4E28004E; Tue, 22 Aug 2023 17:46:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2B2C4940007 for ; Tue, 22 Aug 2023 17:46:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F40241C9441 for ; Tue, 22 Aug 2023 21:46:28 +0000 (UTC) X-FDA: 81153074856.04.34C845E Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf10.hostedemail.com (Postfix) with ESMTP id 33EF7C0009 for ; Tue, 22 Aug 2023 21:46:27 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=BK9+Wr29; spf=pass (imf10.hostedemail.com: domain of chriscli@google.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=chriscli@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692740787; 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=5MUJPUxcmVBLaTsgRdKXZfBt6MGT8IKSbca8jhVu0H8=; b=oyBp7ljP5M4sYBSe56BPKUtw1DoDzrCKtH/w7+k5Si8Qiqz/Wls2i+fIeP0dZoRdxfg2ek yQ+XMPVcaZuERxdUNG5ME05Jeqa4dUdOjrqYGhOrgqmzfxP8o04ZaXGtGSBPPPtTAcSKq/ fKgTOID9lFuiZBm/2F7ekiPP1UYXItk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692740787; a=rsa-sha256; cv=none; b=oS3oD+qpXNhLCHifUC1DMfQEqXzGR0D+m+ayzy0vcrcUNMfQypEn03KzTI6G6syMpfsEiz EOkRDNCJW5Ej644l6nU6r+f1yjbTfWaUhDa1G4yfUiyKFRUSWPRmYKuVL8bj9HWrDH748b dsIdkJdBfqq6cmwfjr6BHcDbJ9i/H6U= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=BK9+Wr29; spf=pass (imf10.hostedemail.com: domain of chriscli@google.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=chriscli@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-26f7f71b9a7so1380632a91.0 for ; Tue, 22 Aug 2023 14:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692740786; x=1693345586; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5MUJPUxcmVBLaTsgRdKXZfBt6MGT8IKSbca8jhVu0H8=; b=BK9+Wr29EKwyTgCbAH6TYt3AcRs4x/XUqyjnbCXOowFeU6f8e4YjWTD0J17tl3fvFV ijsHrtXjtkIvHOTdpmpQK2azcKdx58urLrRgotip/dmjXiCurUiRQBWYu6pQheQYeHFP U7G8z63zQ1ELkz6KYu6/MPWa72Dh+7Aj7a6kszh5f2jKW2oiT5dYYRuWfy+vHDgX2HdL VI3UKdE7U9biI76hKcGsVF7l12SgCNC6HQim5zXfw/JBw6f+61NhZi1jxJC+8UwDkMyl f6PlWxkTDSDwZ4OZcB3tp7rpRiMBgHsZO1I5lZ7JbVKgEVNnKGtvVAxryhxwyc8V5L6Z zewA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692740786; x=1693345586; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5MUJPUxcmVBLaTsgRdKXZfBt6MGT8IKSbca8jhVu0H8=; b=KL5R/3e7zJcKIKW2Lt7czhVVg0HURqFUqrxqGA5gEP1NXwCMfwQ2B1/cwvluzcyuT7 v2tFgPxIkIuM/i2JwARiDZHMKm8rII+fDuBN/AW5wMhcGrFwN1rKr2BbsL4+jV8Xjp1Y zIfIU2TYnuRbfTMD9xRFZB8htGJCGpVz4oq8x83RhVSkxBRMoOtpsKP0jwNs6En9gpc2 OPuAL9bSXvnNjOihaS3G8xH1vH6f0+U1wNf4LQseCciEE4TLCsc5SG3/RSn9Qon/4nEQ OnOUSKQg6RrhDYH37BqoXEVM+b/Huwuh438hINml80i6kBHe1ACYMKgFJplhepJbZhS5 a61A== X-Gm-Message-State: AOJu0YypbfbhJkxFL1q/n24+jukiUqkH92g6e7J+GC5mIGmM5gZPmX2w BiMJUo0VhZHKN5Q2BcMX5t2NQEK3J3yzIp45Qknisw== X-Google-Smtp-Source: AGHT+IEkmUBMh1jGZn1Usgdro918qJSGC6E5Yneo+/9vM4FTAUAx1UyRZ2pcZLap390DZPfpko6TJKuSq0Bcl8cr2H0= X-Received: by 2002:a17:90a:c68a:b0:26d:1e39:faae with SMTP id n10-20020a17090ac68a00b0026d1e39faaemr9137213pjt.22.1692740785827; Tue, 22 Aug 2023 14:46:25 -0700 (PDT) MIME-Version: 1.0 References: <20230817-free_pcppages_bulk-v1-0-c14574a9f80c@kernel.org> <20230821103225.qntnsotdzuthxn2y@techsingularity.net> <6a18b295-92ac-1633-0b79-6aaf18a8496d@huaweicloud.com> In-Reply-To: From: Chris Li Date: Tue, 22 Aug 2023 14:46:14 -0700 Message-ID: Subject: Re: [PATCH RFC 0/2] mm/page_alloc: free_pcppages_bulk safeguard To: Alexei Starovoitov Cc: Kemeng Shi , Mel Gorman , Andrew Morton , baolin.wang@linux.alibaba.com, Michal Hocko , David Hildenbrand , Matthew Wilcox , linux-mm , Namhyung Kim , Greg Thelen , LKML , John Sperbeck , Huang Ying , Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 33EF7C0009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: kxaa6uemotkgyifbajzdriyf41y4f4z8 X-HE-Tag: 1692740787-913984 X-HE-Meta: U2FsdGVkX1+N5atchdUdKNELgkdp5q2SPyr/i0GB+KJxbUKaLjMhgkyb8IvqKPOJqD3jC28WWVH23tMoejmZfau5oZcGqXHfr6GJjU9b7Yiwdw8nXnltTH7Z6SPqhzu37/UmADVLRh3IWNfcIQ0f+x/fWoTesNDZLNsSuSkM32eaSGX1BL6WLyvdow38n/aG1g0ZhqJT4n0FKjKDi3usR9kigDlx2dwaARY70IKnU6pc8pEnOrtFJZUvcm+CGLxP1d+JGIng/5CCX3uHHeu28lJ30zicmWFF7/R3AzylF7335L7jwvUyGbNnsUgJVQPYuMsc3ADvwregwyl+tvFJ0wfLh2WJUg2zEDVfLKfd4aCUR3wFQzi9w8EaAtY9uSnsanc0Oqk2NRBsU4xGE9+fasrYEcficJc5lpu0uQnTIXNaduVtxAV/QA7dGcuNPhTI+rDHnRjJ1j6UMmGBRnjtap35I/zwlWu2fX3hGrwVnHjv93KMMg85vmgDbFQCesV+pGUZbH/UB06nkPKvWvpnqTXu3OqQWMxcuz2ggBtUMiyuDPBQp5VAc5AADTDPlak+MGS/+2FAXDVgYPFPhDqZgdypfVH95d0osRLdVHcdmhWtebN7gfgznS9BSbyJ5q2wCc8iQ1CzVsOFXlcVdAa05/dthUdvZSfOB+KGP7bFDDC7IC6MbB+xWpGTrCxzapFqM2c/N+v/qtk97z03ClRkX4u0gSb170L0YiVJ8HE6JHkdgJk5b68OSkmLZ76YtASDXSQtfHHaAkNRXPjZb04oDQcZ6jnypbEMAVuqWxVsmSIlWGXRhSDrB9pLukVqWOyaq67AShx1UpGJZoCnl5DSaP4ROU5qSndkRqU+8qVj8JVIs/2qnG4piivfcwh1ng9ru6RoigUcUkSO3wrRQgvntx6rp72d2qHcCTwLu5Yw2Jl6ZSRP6eoHQy5ZnxjLndhZxehhRrKWiouTl8rN0OU cbcigHg4 N3LUMvy5CeL0SUca69NSmj61NzT0aDqgo6PpuhLK/AW1akG5N1LbhaTUredvcIZjJkIk8/3fEOvjJ9c3EqhB6wi0IY7hx6UfioWXYIOv/M52o5qzz1r7mA6SMQ0mmbLI5gec63ydUwo/qwmMVR1n9YbtQH+KPFZQ1UKQw9wS0RrOkSN0CwYC/psDWd0MyDlMl+bWSKROyvuSWxYU5+gBqufmOa2SS30wKofiGeDMjGpkZsoT/srUxTifIscngrdsjFf5+Pro9uWwx6XacO8XFDGQaYyyxnVZJ18Q/mVp0PbglGa9sZ2tRq/PiqxxbsFwvKE74AQdtjD9oUrEMal7D99j8imyOjrK+B9eTQezQP6aY4haaxZuHhgZ+H3i/eDJ5sU2wuNhJHCHRiEBI1U5egofpuCiXmKpuQGzXb2C8ttD1obc= 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, Aug 22, 2023 at 2:36=E2=80=AFPM Alexei Starovoitov wrote: > > On Tue, Aug 22, 2023 at 2:29=E2=80=AFPM Chris Li wrot= e: > > > > On Tue, Aug 22, 2023 at 2:19=E2=80=AFPM Alexei Starovoitov > > wrote: > > > > > > > > The execution sequence is like this: > > > > > > > > count =3D min(pcp->count, count); > > > > > > > > /* Ensure requested pindex is drained first. */ > > > > pindex =3D pindex - 1; > > > > bpf_injected_spin_lock_irqsave { > > > > alloc_page(); > > > > original spin_lock_irqsave(&zone->lock, flags) ; > > > > } > > > > > > bpf doesn't call into alloc_page() or slab alloc or pcpu alloc from > > > tracing progs. > > > All memory is preallocated. That is good to know. Thanks. > > > > Here is the other patch submission thread which have more detail of > > how to reproduce it: > > https://lore.kernel.org/linux-mm/20230817-free_pcppages_bulk-v1-1-c1457= 4a9f80c@kernel.org/ > > > > It is on older version of the kernel. > > Please demonstrate the issue on the latest kernel. > It's an unnecessary time sink for everyone to review patches > targeting an issue in the old kernel. Thanks, that is the answer I am looking for. That is why I tag it as RFC. > > > > Can you reproduce the issue on the latest upstream kernel? > > > > Hope, the fix on the BPF side went in as commit c66a36af7ba3a628. > > I am not aware of other cases. > > That was a temporary workaround on perf side. > bpf task local storage was properly fixed later. Ack. > > It seems the consensus is so far is that we don't support BPF doing > > nested allocation on spin locks. > > That will implite any function called under the spinlocks as well. > > We're still talking past each other. bpf uses preallocated memory. > It might look like bpf prog is allocating, but it's actually > not calling into slab. Ack. > > Do we care about adding more warnings on this kind of allocation at all= ? > > bpf doesn't mess with mm state. > If you somehow managed to cause mm splat with bpf prog talk to bpf folks = first. > It's a bug somewhere in bpf. Not with mm. Noted. It started as a MM clean up patch. Should include you earlier. I will spit out the part 2 of the patch as clean up without touching pcp->count then. Chris