From patchwork Wed Apr 17 21:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13633849 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 0298CC4345F for ; Wed, 17 Apr 2024 21:18:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 908096B0093; Wed, 17 Apr 2024 17:18:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B9606B0095; Wed, 17 Apr 2024 17:18:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 758846B0098; Wed, 17 Apr 2024 17:18:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5796D6B0093 for ; Wed, 17 Apr 2024 17:18:46 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E6FA21A0FC7 for ; Wed, 17 Apr 2024 21:18:45 +0000 (UTC) X-FDA: 82020288210.20.6A36264 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 58D522001A for ; Wed, 17 Apr 2024 21:18:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DRK12lWt; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713388724; 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=vaZSbjr/Big1ZTWFV5V3ewRiOJHQfxaJnQPHMzFI5qg=; b=w8CPn3AcyrJzKGJr2+2B9c2XmtUow24LvE9szSzb1mlhby5eRvm4qk8GBNedkrcJquT0l3 l+ezyia2BKJF31PeqdX7Ql677wfscjKanFS21pSlKz51v60WDr/IitdONW8fd75tbYmGSY LypqGIjiDtOT5fVhxo8rhcFTyEge+6I= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DRK12lWt; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713388724; a=rsa-sha256; cv=none; b=3CtP7tFj2vRzxeRD6TAZwuCUJVB4NbvdcWqwjq8M52DV+iW0ceQ9mezKaDzcW/J0XnaSGb sqPiWaJdVOwI3ZOSrl8GcQ9YyKGcZJ0Jfzb+Rn1RdzchepX9Kc0R+ot51DU2itjiuuhuhK D12R26yQu4jsYEh/9c3yqJL7XnURETE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713388721; 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=vaZSbjr/Big1ZTWFV5V3ewRiOJHQfxaJnQPHMzFI5qg=; b=DRK12lWt1z9icAMqhNsiXpMvpqk1bB7yiA2Zvuq6Y5TWC0SkKEmiFVyC6K/i0vRn9Q/2fu cxvKJocEbosep0OCT68GoK8DhqZV/3MNUOg5kdgei104uWpuykBjPDSJqwZ2A0EynuSMtR Dm1zjj0nITxH7cFlYSrjWNdPHPf/4rI= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-8dfBwJdWOguo06mFMIzdtA-1; Wed, 17 Apr 2024 17:18:40 -0400 X-MC-Unique: 8dfBwJdWOguo06mFMIzdtA-1 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-5acdbfb49dbso41385eaf.2 for ; Wed, 17 Apr 2024 14:18:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713388719; x=1713993519; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vaZSbjr/Big1ZTWFV5V3ewRiOJHQfxaJnQPHMzFI5qg=; b=hOZTay+DIA7RP+KiFnnr1y+uWhHWk7NJT9Uj01jksyfge7UxVZoJ6dLaf1EU2t/F2U 6TwI+jSlISOZKYizl7yg7DxDEEIw0JijbiBU5X131F7d9u+0Bl1kwRY7T/j/bLbDOXmb 5XDeXKGY90xU1tKegniycixyEt88U4tJ+wcdmljEi2a6UiZx3gBtK8bgQz1Jtq6Hjiqr JVivoX8dr6WQX2ZPpuJlD3SMbhXS4RTz07u+hZsoEU6O0Lzgv41mDNu+sJN+VaSdQrdR 4bs8A8qa0HrIt7d4fcObw+7lOz1mgVf99wnyLIHj+VeMiHCjJ623G2/RBwF/PWtqaa+F PzXg== X-Gm-Message-State: AOJu0YwTVWam3ohQAaVV7Y4RAauIyQWDoyT8zKdKY3xRJtJOqT/2vgQy Y0JOZmMEdw0hwNo/Sigx8HscaU+lvc+4Gr3Fd57dAoLs26NV8+aUZO8Nhj6bj9IfiGtb7LYW4OT NV0fwlKWMhrjjr7DBlrB5y3EjnVQndV7kOUufd6OKfN4UsgdGbzUp9pUmMvUCmtiGQ1+dS94ZBT h2eJ9d59al6kM479KBk0OkuBHj2aKz6A== X-Received: by 2002:a05:6358:5903:b0:189:a9fa:f512 with SMTP id g3-20020a056358590300b00189a9faf512mr791818rwf.0.1713388719406; Wed, 17 Apr 2024 14:18:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkJAo39kjQ/eDy9sVg3usabpSgplaT/SVidXPJ26Le9qlIHvGQ4T7UGdRB3oGfYwJTy6M4JQ== X-Received: by 2002:a05:6358:5903:b0:189:a9fa:f512 with SMTP id g3-20020a056358590300b00189a9faf512mr791783rwf.0.1713388718852; Wed, 17 Apr 2024 14:18:38 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c10-20020a37e10a000000b0078d667d1085sm18692qkm.84.2024.04.17.14.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:18:38 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, David Hildenbrand , Mina Almasry , Andrew Morton , Muchun Song , David Rientjes Subject: [PATCH 1/3] fixup! mm: always initialise folio->_deferred_list Date: Wed, 17 Apr 2024 17:18:34 -0400 Message-ID: <20240417211836.2742593-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417211836.2742593-1-peterx@redhat.com> References: <20240417211836.2742593-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 4tfkfhtp63x73nnpn4yn8ck359zajour X-Rspamd-Queue-Id: 58D522001A X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1713388722-854299 X-HE-Meta: U2FsdGVkX1/BpruIq+MwHpiRpnYm+taUSEPM5GL0Q1Ho/K+mdYA8SWpQnJpDn32lo9l3x2HfxheKZcCTv66XacFvDrL+xdT+i1Og0HrTPN70zyO1cte0YH8G27Q3bdOBcyRI2fxkWPDluADhC1Ki8xCyzmuQ6w8OU8G1fQlvNCxskZ0IhAWDVtC3vjptLLCW4prQwxQyZ5HH0HgiYaxTkCoJWnD68IFpyfnUqUyvZH31LDEdRrCvwzHunHTZELBe4SL7gQaGoC/jIwhlIlwk2QFpg3CCgWhHzSJBSirdT0XWSPCZn/vWqPW3khbu3WnztOiWaOcyWr2gzHwj2JC+4aGp619uha2Z/qgFLMM7nIob/ktVmVcbP/AgW6q6y9WAPsKDLkfLKoE4cyE7+BZpwldd1E90RDKgV959yZPdhA3pAFZ3/k0EsiO4biwh0xGj/rcppiz/mv9p2FZC+N9BE7+/8IyUDETCBct5jMCt1QHBdEFPr9Uyx4JZiXc8mfTyDzYk9SsAy67/HOlVWOiBCMJfu0Q6Um/ntYUWMVeZo4NeWUNnFAalZjxqHq59CcqXMRbgQOGJ4fWbAx5nUZjoxWqpZQBi6yUjDZCPatz4pWrKpWbf0NfCj3UWeWgGgq7MTuZh5L614qSY0L6FJbOYJgypACx5G8V7DutVzfZibDQ1clAJ6i5S5l72nI6Hg2/R7+LRbk96QrEQ/p2IbCI6SygAQ183fTBVukSP4sq6bPtJZxEIyYndR7FYIHAfubx2lppnd8UBuTSPZEg0IL2PAmpCZIDeTgKTLLFiXWnfORmZBGsmmBIYl0YymMxroGYvVTPFwos0MIzQQ9sJkAUJuy2rgTN30R55fUE79I1PE9Yh6RFfNn+rccmzNvnCIaiJj+AtxGYd+1g74ZL8AsrvIe67sIdHg1oLVs/F7AVE7vLpQDi7eP3khOtPWoHWyPFlr0O0ig3cTJmNAO5CMGZ 6CVw9mza Dp8b0+6r9PzQlz5RbHzSidJdsnFZJfrrxvHI2Xw0r7CfgxE8oquncaiYFFcAcqHAcTDyNP+iMEr+cC9s+h35fccQ35PvRgaAGLoLVAQ20Zv9/beQfWxssW3zFOQk/nk4uwi82DPlYpCFxCDhSFXd/nP91X6e1pgar4q+tW+5qcLGsswVXEK5kSvwoMA== 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: List-Subscribe: List-Unsubscribe: Current mm-unstable will hit this when running test_hugetlb_memcg. This fixes the crash for me. Signed-off-by: Peter Xu --- mm/memcontrol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1840ba4c355d..7703ced535a3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7529,6 +7529,7 @@ static void uncharge_folio(struct folio *folio, struct uncharge_gather *ug) VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); VM_BUG_ON_FOLIO(folio_order(folio) > 1 && + !folio_test_hugetlb(folio) && !list_empty(&folio->_deferred_list), folio); /* From patchwork Wed Apr 17 21:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13633851 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 B4762C4345F for ; Wed, 17 Apr 2024 21:18:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6249F6B0098; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 585366B0099; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ED016B009A; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 13A476B0098 for ; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BD94FA0628 for ; Wed, 17 Apr 2024 21:18:46 +0000 (UTC) X-FDA: 82020288252.16.0C0B6E7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id DB40120006 for ; Wed, 17 Apr 2024 21:18:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TD0XzgHp; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713388724; 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=soVIv7S/cFD39BpNRdoqoVyCZSY1hvphkidLWmkZkAI=; b=YRNBfisLZXZn9zaqBfgUVzbdDXhnbehK4iwFKDI8rjFWiZh1hjDCiXtlWnqZv4Lw34+qBz MGrYhIC4nRmSlb+nOiIM9sEjpm21fihKXhzqC/g6QuEwBT3vypS7CUN83ncFlacOQ3oSv1 DIkoPaR+NBI9iBKHeVi99RViCLAAX7U= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TD0XzgHp; spf=pass (imf03.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713388724; a=rsa-sha256; cv=none; b=SeBnJGqdJ/r/fbZmm63/ZTG/EukpvDeD/lcRbD6EiQzXkR/UZ+m+oBSsc9GUrPZT++fY0f n1IRqz70LTxCXxoQ+3MZcGhb2Ix5b2WB/0C0cadcBr+PF8pGNtFsq5mBZVGMPdmY0pcqpe 10C4QMdZMY9dvkclFKTAmiHsn5QCDx8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713388723; 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=soVIv7S/cFD39BpNRdoqoVyCZSY1hvphkidLWmkZkAI=; b=TD0XzgHpJ0ltit/3aDVJjStH5IVPadWnuDarw9JWIIh5kApleO+dLymdNSnEUdrAvyh0vg Do0pBwaxTPD+kiWcOYVxg9dxoEHNGoUAnOn+dAHnz/eKuimUCd4GQRGDnNOB2zJLhxS2c9 DUFuaRJ3bMXN+HDtb2RwV45dWUMQFQo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-NKw568tGNFW3l7-Y0QdeLg-1; Wed, 17 Apr 2024 17:18:42 -0400 X-MC-Unique: NKw568tGNFW3l7-Y0QdeLg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6a0426da999so413126d6.2 for ; Wed, 17 Apr 2024 14:18:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713388721; x=1713993521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=soVIv7S/cFD39BpNRdoqoVyCZSY1hvphkidLWmkZkAI=; b=w3TMTKDV38tLScs4wiYkcd8NH5LBswp059gYwMchXOzh7kmiglO/X4Lr4oHEP8rKKU HGZvmLUQdiqtJ+YgIZ28gzBqB+knFhfKYTcBGjI7RSJzT2L5jt9l7OHtEyeq5l0h2gEW oItoi4RlXviLToPY8h/YzKTH1tFARFjVZTAvuU8D2GvH0/C12nnoaiUoUmwGwlUC5jwV 97zP09rHj5HkTGXSo6g9DcEeiUjYdui4Bo5YWTqA+q5tt9B3NSVO49byffDNSA+rAVUg NEi06MuuleLqgg4dc1CW7wruBDQANHrUr5XSQ7TQ40C4amfYAW/xzB/UXun3aSwDSgak 49Tg== X-Gm-Message-State: AOJu0YyrlUwPlm4OHs9c3HSufzZJ2Zg8tq3pqwKK78KrwL1eOUXa7UKy 9GbXYugIYAuwdPhcfq4OrjcuIPTqk5J3w8woIC4PuiU0DqLWusZLKzLvcDd+iNVxXL/8Jj1aVQd wc4TPMr5r/x6/4t5BB4Tk9I2HQkxix2qK7jdb08j2673/VSdfH4/1xM9ngzFpN96Hts/aKRCYs8 a5XTi0zXOtby4Kuv36JfR4TmMLqou1qQ== X-Received: by 2002:a05:620a:40d5:b0:78e:db4f:11e8 with SMTP id g21-20020a05620a40d500b0078edb4f11e8mr665748qko.2.1713388721186; Wed, 17 Apr 2024 14:18:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF29e5f56ETIzCUQyLUa1pQN9jUqXmcKYHsWC/k2I1kVI2Yma0QJE36x4pPxkZnbBNtERvaag== X-Received: by 2002:a05:620a:40d5:b0:78e:db4f:11e8 with SMTP id g21-20020a05620a40d500b0078edb4f11e8mr665713qko.2.1713388720577; Wed, 17 Apr 2024 14:18:40 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c10-20020a37e10a000000b0078d667d1085sm18692qkm.84.2024.04.17.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:18:40 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, David Hildenbrand , Mina Almasry , Andrew Morton , Muchun Song , David Rientjes , syzbot+4b8077a5fccc61c385a1@syzkaller.appspotmail.com, linux-stable Subject: [PATCH 2/3] mm/hugetlb: Fix missing hugetlb_lock for resv uncharge Date: Wed, 17 Apr 2024 17:18:35 -0400 Message-ID: <20240417211836.2742593-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417211836.2742593-1-peterx@redhat.com> References: <20240417211836.2742593-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 1zcgr5u76h18a8x3noh6xdhz963mfp38 X-Rspamd-Queue-Id: DB40120006 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713388723-44132 X-HE-Meta: U2FsdGVkX18Zof14laQUuwfyhjUtfUpogAo/dVpIPAoaJnMnxsV+TDedNij7uer0iouIE1oKO5kcfsqoRvYeu+4teRFdw/7v8//j+bAU/2rxrcHpKYpXPPQrvRkvVW+uhckTgOL1jO41BZwTByu8pE7PpFUS7KgAM5h3tn62PgrkvlX5GwCYst/5AuEUR40dZGvS+AkzT13zuV/eu+NXUFPJWJkt5ZjUQXGb7ocA/Xv6hOElZFgXHE4j1GxUwc6toU5M/QR0LGt9L5uDMjim8TkT1Es64FYtUBzmu0AeAhZNaYfhUd+C1FPaGLCGJIFjnHEFYkk+HUvoQCoEmAxU7ghgJ/ksE/PoQWDtIbvXeD3H/iLzTpUCfImwsrH4cqtoFxZXRREA5AZ8niEkY8PLOugig1CSU5e7hDLhJKW62yKKMkugD2wrrTQILx85XL5Wh0zErqP9hW79P+xkm/MJTUv5x5+67klyssKPbJor77R3ENel+DGZlN5sWwGGthQ4uGaYBjvb00iBfk0ZnrbADRAB/48Y0lXdnfpSwmXh44Jr1Brm+Sk+r1oC9KoLJarWBPoGD4sU2zRdS+dZgQkosAsAl16NKZmZudJJefj8VQs+y9ypF3vCy7h8R2TrcK81zoSNfcYrkT9TmzFVsKr8sqf8NgI43e36mcOzn2mnh7Ab/DSOi0DyEwk1W0UiDNUnxSQ/1gFby6cn13bSO3VJg3RH70FnmsaJUxQdjV2tAeUVdnCLyA0PaCAegLjhDKaRZelKFTgNfOG+jIBSe3fi0XFxxSKOIc/afHhDFhwiu5SfEU9913RA8bej9GCzvEdpe+0M0hJYLYvfZl7dZHb8n8JfgJNBmzVD+j1JFhybnvtk/YQPYDit8ikTdgm6gfm2CxiVHCXE/o/fPN6IDterim4qQSnjRqkn1gbOiExvBh2XdLJatOZ61FXm+A1ignl22idzu8VO5VtAavjL1SK hqEiRRqx qHC5LGgV5ioLhvkPERMgtLv9MZHQHgYXOU18A68d3dSvrQT8ni3/FwWQLofAw7zEYqkzQaimvggyL6d576bs7TuLDxmJpn3jhPtY89S/2f6I0GcRT7K1p6dPgNXRuX/tUnSCBETJaxLpUekoyCZfza9Z71xbZDBuiMKNHAq3qsQ8q9AavpPWHWnK8LzEbu0Js/0VzAohQ8PjX8t8zoyQChEseFyzGcv/0sPPsv0hC0AuAUJY= 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: List-Subscribe: List-Unsubscribe: There is a recent report on UFFDIO_COPY over hugetlb: https://lore.kernel.org/all/000000000000ee06de0616177560@google.com/ 350: lockdep_assert_held(&hugetlb_lock); Should be an issue in hugetlb but triggered in an userfault context, where it goes into the unlikely path where two threads modifying the resv map together. Mike has a fix in that path for resv uncharge but it looks like the locking criteria was overlooked: hugetlb_cgroup_uncharge_folio_rsvd() will update the cgroup pointer, so it requires to be called with the lock held. Looks like a stable material, so have it copied. Reported-by: syzbot+4b8077a5fccc61c385a1@syzkaller.appspotmail.com Cc: Mina Almasry Cc: David Hildenbrand Cc: linux-stable Fixes: 79aa925bf239 ("hugetlb_cgroup: fix reservation accounting") Signed-off-by: Peter Xu Reviewed-by: Mina Almasry --- mm/hugetlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 26ab9dfc7d63..3158a55ce567 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3247,9 +3247,12 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, rsv_adjust = hugepage_subpool_put_pages(spool, 1); hugetlb_acct_memory(h, -rsv_adjust); - if (deferred_reserve) + if (deferred_reserve) { + spin_lock_irq(&hugetlb_lock); hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h), pages_per_huge_page(h), folio); + spin_unlock_irq(&hugetlb_lock); + } } if (!memcg_charge_ret) From patchwork Wed Apr 17 21:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13633852 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 0D16BC001CC for ; Wed, 17 Apr 2024 21:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F284B6B0099; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAC996B009A; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C61F66B009B; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A2F846B0099 for ; Wed, 17 Apr 2024 17:18:47 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4A37540FAB for ; Wed, 17 Apr 2024 21:18:47 +0000 (UTC) X-FDA: 82020288294.22.9122F60 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 1DA3D16000E for ; Wed, 17 Apr 2024 21:18:44 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AjoxlII1; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713388725; 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=RODytP55S9PjZjf+7gfJJ4x6mavqXkgxb7Ks2uWHAe4=; b=1l7RTzyWvxvFje5Dl7+J/Lvc2nfa49yfePk+1HhRQslj3DcAdPuMwHCN9dnGS0toBlI4Nv 8ZXMBRGXbKvhHMWSAzlk2eGRiSA42bL5S0RvLqS9bn0KPABudS6YQJqJ41edvJRKaGPdmZ iCt5GtG0+KsCjfUCYMV3FVWUgZIl2Eo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713388725; a=rsa-sha256; cv=none; b=IOOweMX1v44i/qy6qfFTp4JwF/78enXPxvA/TlJW3CfJvyU6fYoStsR91R2x0jaclJQBtS gfI7WvguScUWto/QuMvjlOoSY4pUEdSCIjIhSq64SV5BORDUEiMgN+Vn3+OXBOiuOpHFe9 tFwam89pLZ5unM8t6xZVg/Nx/RMV/8c= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AjoxlII1; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713388724; 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=RODytP55S9PjZjf+7gfJJ4x6mavqXkgxb7Ks2uWHAe4=; b=AjoxlII1AiOMLIGuUdtQP5Q2nw1o+clfyE3/a8ydNTQoBhTu9CMjyqXRhYnaDOGpV5Pu02 RhEvmaklJXAvWPU9MQs/5174P8bwNbJg0fMipjoYXB7RF6P+zO1VFuijHo4yJ1bqs2qo6v vi5BYhN20qYfTGvY+xi1yME8KB14Wc8= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-nxpRz_rdPCyJ3s2_f_pKZA-1; Wed, 17 Apr 2024 17:18:43 -0400 X-MC-Unique: nxpRz_rdPCyJ3s2_f_pKZA-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6eba7dc8f1dso26814a34.2 for ; Wed, 17 Apr 2024 14:18:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713388722; x=1713993522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RODytP55S9PjZjf+7gfJJ4x6mavqXkgxb7Ks2uWHAe4=; b=FPA9MMxfz8/BwiqZZJvEXAEEhbyH8hQVGIJxlQKvIWF7CSghsCp2U43T/jSpXvmd+W UM/vjIDdHV/6tN2L5HwmIIVgKyU7TGPLVE3QmcCOx2f1KarDg9CFU4oAz6qFjepDBhwn F65s2KRn+D459iP9j+X+0IgGTVONWDOm/UHK+e3ooRYhf3C1fpVhnOH50+/3Vm+56/lq QLgtJpf+68nEjuSQkvwpvFwGkLWoRyISNwFTfSTKuJR5LgjMdcvSAdHNJMMdXh33iJ2f czAlgB7utXfLqIqoD35lSbD12XGdcW076wGnuqV8nd/pRs9gjWkYXrBAKi6XaDMv9wYb NVAQ== X-Gm-Message-State: AOJu0Yy74Il0pXhG2PsPBGAKJT4+DdoE0ZQbj/nFq2deIjqMcTt6fvCL VqTX9reiFUeFU0L9P1CKasQuEkLsz5WWGAcVCmYb8SdRJY2j2vc+SPdZeBK0xbIL4pQ+QHYcKJM YY3JzUSKOPTRVyeJmAdY95WgQZey3F6cVBEawGCDCISU7g9QaHJt9Cwry70OfXUdr3PUvWS9+zd XtA2Qt/tKAEcn+12JeZmlSxYjX0Ja2pQ== X-Received: by 2002:a9d:7406:0:b0:6eb:7e33:3fbb with SMTP id n6-20020a9d7406000000b006eb7e333fbbmr838913otk.0.1713388722177; Wed, 17 Apr 2024 14:18:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGQuu+Ru3d/WAMoyXikWuaGubuV6xaXPDqyX9q9vBRfpwd+WdeOnRC1LPB2iMpjdigzkGg1g== X-Received: by 2002:a9d:7406:0:b0:6eb:7e33:3fbb with SMTP id n6-20020a9d7406000000b006eb7e333fbbmr838884otk.0.1713388721661; Wed, 17 Apr 2024 14:18:41 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c10-20020a37e10a000000b0078d667d1085sm18692qkm.84.2024.04.17.14.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 14:18:41 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, David Hildenbrand , Mina Almasry , Andrew Morton , Muchun Song , David Rientjes Subject: [PATCH 3/3] mm/hugetlb: Assert hugetlb_lock in __hugetlb_cgroup_commit_charge Date: Wed, 17 Apr 2024 17:18:36 -0400 Message-ID: <20240417211836.2742593-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417211836.2742593-1-peterx@redhat.com> References: <20240417211836.2742593-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1DA3D16000E X-Rspam-User: X-Stat-Signature: a6g7i9p1ymjkwugghjx19hy6wpkpx6qg X-HE-Tag: 1713388724-8863 X-HE-Meta: U2FsdGVkX18Lt69nAMy3R7QUCRHLgDNz3OvCjS2Wqo/GsedQYFeXfitn5UwndACHOmRoPeiwvLDEs1fowWPKe7tTwXTrucc/ztCiAQYEALJNunGMT+8g77faGke7BU2eHxtHaq+UcahfZqvQUTElq31p15NdNlvGhF1yEBSIrkH0ofDZJkI03RjKf9llEIb+Z6Q1ZWejbJBxu1acslhXwuqHbNcuKxjvZm+zYn4EZ5KkcqfF2osfOB0HyHgEwX5i5ns5egxvdoDmcKeOIGHmy2nPD5EpyFFBWPzbnyr06HW7aIS02rZv6k/ZQXjJ4gECqB8Fp6bwXXMhUtxhMWLUtYJWGBPoAeoXkj2hOpYr7WFWlLbKSoGJMl9x+QnDbfvWvlmlkfmPwFOBaC2InEN5w4Jmi6/DP0OlammI/xv0PN9g/6c9x2REaACiS9c6yWcgkYZn4Q48hxTNC4DLGZXYz9jPZNQtGU6EurpM4GFJy953HDSbQrnH7K4nY9m2m4jG9FSAJOUnPsQcGknKfjYs9hn6Py7HBn/nkUc2eDVFfGS5JjWJIsj0aKc+cfumNayl9WQiT9lnLC5LDmOCQQLvpUK23HvtVLqJ3B8v8Xkj0RY5vk9U7xRS1P1rMkBUSxVSINx0BOe4QSorZrVZe1nLGYQNQhIWnukSIf+Prd31vtCZd/A63OqGFvzBYqwEEoRWWreDi712vt4IzkCiYxrD3b6vAdFAH5q7jnRIDA0PJxVDXBZ1lYYJztDAWMesDf7GFgJiRLgVLzXXZkEnCaDRcLk9YQBz0FyPQ6jwVYo1VagEPbC6KLZyfFsNRg3rcz7Pd7WviiBbJtFCy+8dF88xUVp7dv0sfgTaopaRaTNHtXMIjy2NkOhvUgHIR9VgcOFiYywDZmSTd8fLGbYbvsx2bO6Hbnx0FTIPv1rB//z778+GhspHlSmv1GAPiD3Us4mqDrZgoG4ASfzTMHc7z/Q Vkyq6irb pKLrRNV7d8Hj54uILEaNj02pPstn5OvQkEflzP1o9WbQyeRnPIhKhBoTmPCBSCMUY0rvDxoa+RVSIFEanr2PXt50HldWi+yenMA54RSLGJb/QhMwZHsYf0xMZve0PwuZz2QZVpWzJiseFUSXk+kMjYv79n7zUysm6bU1LvF9xBNVaY6sp8crsnPMPYxVhNgh713J9h+Jo1Es/LFg08dF68/KL7g/JE1owgpYhQiQxL6csYuIWFtgJPAQJ9P2DVZTtYjQJt/GMFr+zmFTou7kGNmma03ChgLZQUOaP6LH/Q6ciXKYId1UrSKXGxhgxY7o+hSNz4nZwIrZOMEcZSJgLYCjQOoi952zi6EcPlNnp154raK4R1mcNurh8H60FJmsSx4Wqs96Nx5QZx2c87BI87KtvXwTw7OaKtP7QFFj1s8rqA9GN6MmMFjbjSg== 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: List-Subscribe: List-Unsubscribe: This is similar to __hugetlb_cgroup_uncharge_folio() where it relies on holding hugetlb_lock. Add the similar assertion like the other one, since it looks like such things may help some day. Signed-off-by: Peter Xu Reviewed-by: Mina Almasry --- mm/hugetlb_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index aa4486bd3904..e20339a346b9 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -308,7 +308,7 @@ static void __hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, { if (hugetlb_cgroup_disabled() || !h_cg) return; - + lockdep_assert_held(&hugetlb_lock); __set_hugetlb_cgroup(folio, h_cg, rsvd); if (!rsvd) { unsigned long usage =