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 C94B4EE49AF for ; Tue, 22 Aug 2023 21:36:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B795940032; Tue, 22 Aug 2023 17:36:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44121940007; Tue, 22 Aug 2023 17:36:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BAFB940032; Tue, 22 Aug 2023 17:36:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 135C8940007 for ; Tue, 22 Aug 2023 17:36:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D37EF1203EA for ; Tue, 22 Aug 2023 21:36:13 +0000 (UTC) X-FDA: 81153049026.18.D4B6D64 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by imf25.hostedemail.com (Postfix) with ESMTP id DDA2BA000F for ; Tue, 22 Aug 2023 21:36:11 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QrxdTx2A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.208.181 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692740172; 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=5LHjOWGMbGUokbA8qWX5eAKbU40dKCMt10ItvXVx9pk=; b=Pm2sA+D8xs/XumM/dMuweSH/To70Etg6eJhsi4hVH6DNkTnJpfTau7KD8JbSfMxcWpkH0e yeS5pqRxeUUNhz7++5Hp9Kv1VYV3GZTswKr2EDyo3NY2jJ3KdPp6ex9vaEZd5lLErN3MO6 ZVxeqw9ptTiLTzlCbs/WMAfY82fG+FU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QrxdTx2A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.208.181 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692740172; a=rsa-sha256; cv=none; b=W2SYjKVpGlpxbVYAfhldeb7kf9/shdfTWLV97HX4w8M/V6+ZIOh3B86Xz6B/DrJlbpqyCr 8LhkQEI2T1gMpt9kjjpwRvPtxg0bvIq5TpUfxCmBVtb9hGoAlG0iQfT5Z6smrF6qVsVCMC eku4VzYpi1ycmVLCqjOHDIFpezfvXT0= Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2b703a0453fso83276571fa.3 for ; Tue, 22 Aug 2023 14:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692740170; x=1693344970; 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=5LHjOWGMbGUokbA8qWX5eAKbU40dKCMt10ItvXVx9pk=; b=QrxdTx2A/tl6u8hz5Vk/lr1Bx45IZkwv3u8lQZ7sYP5yZmQSX8QoQNz8lkzSRpmfIN FdYsuqhbzuUZNaqyLMFwb4QMllt1U6J/varAT5eUPY3lm2IkRCB/MV+R7ONL28uO006P tqIk1lUeb5J1JelPWkPBhdQ9/PUKSwtTJ7BtEpgVtlECXgCylbGn9YQDtQr+uqkcaibE aLeFIixp+Tnn2B0nRTD/jhx2z2o0VpbWyfmgiboxQsC9qxqBI6g02tQ1AidnOqPDOx77 043q3LrYnShKd9eUbDTVyDq5nAB9OD2lW4PFyaX0tucKZtMVR2tXaxaQrjxm1peTFNcD aXYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692740170; x=1693344970; 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=5LHjOWGMbGUokbA8qWX5eAKbU40dKCMt10ItvXVx9pk=; b=eJiMSMkzAqzsAoe0aBgqhd/Amd/vw9fAW/XYhyA3P93IWtk7rATR5455m6ZCAEXeul 0eJN9ogVDq54b2niJLRD++jQ06gkyrcwh4FITkTe/IzyLFxkXddk/42aBa1DRvYy5y67 C9laoDF+CLe4wIcIOhd/k4AvzMBIdMnQlBDvucwEaXzdEmfCGegUnQ8wK6oINrF2+7R4 ISXADr4sQjLhFBPYMVYcQP9QYuGMK3UtefLaGlZvThMu5EayezKICFIDgBZaH9Lojxxn K6ZDK3XiCfL8qV5Z6mly7xWCP26XKHf9GSB4IH2Ep9/3zTeozrd/PYdNWRjTzSkmCw7Z SSmA== X-Gm-Message-State: AOJu0YzSbdGS3fnLqXOWGWVmyQQ5lz2BI+Xqxyaru1MPaPXBC6ZxlNln /D1sfVfQA7EYm0csViFugOP7JFQ2zZf4jRCJs+Y= X-Google-Smtp-Source: AGHT+IHctqN/U8j4Kr4pwXmL967EF0ND3jL7m0J3rg6bQN/XuHej33P3WqFfMPURTOnlFWl5drp+ei5ZFFpIgWOxefE= X-Received: by 2002:a2e:3207:0:b0:2b8:3ff3:cd93 with SMTP id y7-20020a2e3207000000b002b83ff3cd93mr7174536ljy.7.1692740170040; Tue, 22 Aug 2023 14:36:10 -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: Alexei Starovoitov Date: Tue, 22 Aug 2023 14:35:58 -0700 Message-ID: Subject: Re: [PATCH RFC 0/2] mm/page_alloc: free_pcppages_bulk safeguard To: Chris Li 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-Server: rspam09 X-Rspamd-Queue-Id: DDA2BA000F X-Stat-Signature: ep45pf4yftz6fstkix8ja4ij1yk8o3oq X-Rspam-User: X-HE-Tag: 1692740171-699710 X-HE-Meta: U2FsdGVkX1/yoHAJNRMnOvH1Jp0AeZW8wgZUPffw6SJ3BSGsT8x6OtAj7htox/jt0Q7fWnrwWC6VOKLuaEGVONqddS0YVCujBWwLEO+HT4gc+OXorCh7SUk8vXM+D0f/BvpWplMSI+SAkfGOfVZCDomJMBentEO3eNC68GXfi2dKp6ugFATvCTrPVjkBwi8nZs34vAQ/JIIBETplaY/yA4DHzgPrDtmXxRP6GgTs3jXY/m/+QmndvPft+LWehgIpuxJEeTaLw64nNx2cwe/1bqAe3QPmXY+fHopy1wmEaXrSZ7T1CY/JPhyq1EIX0u5GePo8pToUQw7Pkb/s1rllFpOxy0hglv4sYXf0IqOXdFMQM7j05I1J3dBJ08CXIu2d/VPLAnuoJdu+59QwBgpZZBtz5qRRxGe288mSWXLGje251Iz6rAOCWzXelihGosfPouzG/sxkSL7mNZfUsLknNEnRK8OD8WV3WAJcaULpWD7jPI253f26ymV3QFh/b9X/XTOpFYe9kUoAj8zR6IIafNKc2AkY9md+8mIH5LoLeiEUXCeV/pgSsyjdH2Pb08X2+NzIVmD9tN7p2pxbw8Cp3pc1PERV83Hnuq3tSp0TmpnY5ABwoog5HmsF70UpPvExy33Zqx4Ck9OBEJhvijrQHiFVg63z966vDMjgQogwpwaeJBSVfnCg0ZwEE4Ne/tobSXms01yUSMjLmiOj+ckTQdZAp8ecrndu+NuBJaASDTDRk0imCf3bCsqfPHSzm5PvQ2ZUZU6yr6GLIlRJUWpfWKAgpYNZL289kyKH3SzuHmsUkAKC1b+OLm7JDbd2xRbU3A3ydbVisKTQMN3lNfZzpK7wlncpdjN2uYk3f5Kc5m7fU1px5F7Ihl5vX/+UNV1sRCnxZx3SA6Na3+VoyYv3aAyZ77I/HT/IyKjMcxLQyIi6wSR0Co+09tgMfDhcnmjfkHwSf9ELy041fOaIeZ4 xTLR7JsG VOXdTaLAUBXTfmH+rmWZYf0EfLa/3yN+P3aK7wal3tM1CylZiGj0+uFQpmxvCAPzFFK74ixY2ln+74JprntW0JFHsu/LOlOskPtpmZfGrTAXYVDp3HcFEHaY0gTmbaVGEnoIuT6ZJKCSg08+eiilY8ohRaxOk9Q6oAC0qyJQCnzVFN73ids2z27mVCkpmz4yQHYlHz1NnrH0wuBVVMNKAEw0AZz4zPwURBZziYqKPMid19P1lxh1tYUfLtDbivSOhAX1I+5tmpzvfVQUBEzpT2klJbRlaPBH9e3ka/IqibpFwTYwfnKf6J4EOgZTx5W+77QUl8hlP34H7nI/R9msah4I2JthwSwlMC2VZG2sr0/LkC0Z/Os5K4VCkvsi2aJp7RD8+tPmw4c7Co6nnqrd4OZn9C2L8zR8WWkZZmeKVknNVfKMrMk6D251aRtl/xFi2pvwS1MRGlyINGJY4wK8PMH0k3QaOKJq/3gTTk3b4NEjASmSjMc15XLox2Ryv2BwDgunCvywbuk+JRCc= 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:29=E2=80=AFPM Chris Li wrote: > > 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. > > 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-c14574a= 9f80c@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. > > 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. > 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. > 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 fi= rst. It's a bug somewhere in bpf. Not with mm.