Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1278270lqb; Thu, 18 Apr 2024 05:41:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbNfAE60bUe63pDvCeI+C7VwIXukXKP39yvXknynz5y01sN0DXctVKkbg3WpB9hvGfX8xoB5PpVVHNo+ey37pSisbnKiS6Ghx9Nli2Xw== X-Google-Smtp-Source: AGHT+IHrXImCZaP7zZ6ksEndLMu17XI0PGkpe5rWVfdbyBkc5pyos+U9zipkPmxTBo3MX6dgnqz5 X-Received: by 2002:a50:cd04:0:b0:570:3b8:a990 with SMTP id z4-20020a50cd04000000b0057003b8a990mr1800209edi.39.1713444097419; Thu, 18 Apr 2024 05:41:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713444097; cv=pass; d=google.com; s=arc-20160816; b=Wba5AUtxjbEkdxKym8HETqckOa9GawSSMoNzDfAwV/VaHjeKffYAFbBtcpUMZUldqE Ic67ajG9DmQ5wFSu4VBjVHQJqKKq9exh/m2kvozje/lN8uO0bR+2LTS7PKbcqlozdykC HzFtg8ja29jHmqr2Lu653kMNXnVa8Dc1khC7PCjlcFoL7qkmmBS8ZNjYmfZMDK2xLZE1 RCMRLXI2C5Flbiy3sByCVU6DtnN3fPwxs0ckaxbcnw5SYvheABJlTgIaatLpI8eybHSN +wM+2FRTs5pbv1fvfb4JwwkXwAlrFOys66L1flUPSIpF6iikTqX0PELre/cvi61/ERBG 0q3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=U7DjYF/kzJVRyzAMWLo9U8Tt/CvqZCHiGjMu2GCpIDI=; fh=v9Uc0Wn6wjglIeA+1bDVz/c+GtBDLszNd6/cahk1Z4o=; b=RzJu3QkK4zBrIESSjXwfRBKjQyMNJOdgcJAJwbkzhDFto9LnjcpTh9/KWl8i5tWKPR NWNxZ0iKYrPBGs5ioep9Eb6c3hjLiznVuU/diJ33sQsAlowlSbTRGOHZwBmwJTfGwd5Z upfK5BElKcgrl8cUi5oacteTUJg+R0tvXQhvLaTleX69yduZyHboFYug4zA4tb/JYJNx u69+pu8GI5tc5rcZLTk5mUwSYzrSkqqEg04X6wzp4yl9utqlLH3bwYzopfAga+HZtyj8 9MHeJt4oMOcUCk1wTFPjhUhs1YWA5I1rYV4lkjXvM0Xe41afG2KvPrC4qckR8SIEIcxV to8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Do9eUX88; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Do9eUX88; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=wwjPwJkL; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-150074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y12-20020aa7cccc000000b0056e7470d8e6si794497edt.173.2024.04.18.05.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 05:41:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Do9eUX88; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Do9eUX88; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=wwjPwJkL; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-150074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 016B11F21FE7 for ; Thu, 18 Apr 2024 12:41:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D183262A3; Thu, 18 Apr 2024 12:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Do9eUX88"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wwjPwJkL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Do9eUX88"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wwjPwJkL" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 219B6182C5 for ; Thu, 18 Apr 2024 12:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713444088; cv=none; b=ovgbfqZGi9w/Eq350DSjBYBUfJTruMnaBF09WwhgUbogg2ZZ9qq6zL3SYaKTaAsd1ARzDsSUJyoBleD0EEzAZcYbsgPjQPbrc46KALmBokuvKEWjZqn+hztGtsKR3IMHwO763VFaJPIZ2KLAHuT11PS6OOG8Na0oAJyUZbzPKdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713444088; c=relaxed/simple; bh=Dot82zyMxUe9JpcgnocyYwO3KhCnP0t07rc/4gubA+o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LZWTMvGLZqcXAajYfa4IFiRChE4nYwyRJTvV9wcW0+SWsd8Lqz4ytcxHoRrmyPSIrHp3Xwo7VK+f+Joscf77KyqsD3lm1KMEPPx5xlT2w9tnxtmuZzboA3tRjMgb+cGBtfWnq4DgU4ZHZKcmnnrpJtUe10MN0SwMHCHV/X6dQgo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Do9eUX88; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=wwjPwJkL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Do9eUX88; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=wwjPwJkL; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 18E975CA7F; Thu, 18 Apr 2024 12:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713444085; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U7DjYF/kzJVRyzAMWLo9U8Tt/CvqZCHiGjMu2GCpIDI=; b=Do9eUX882YqcS8xoSEeXDPg4XTx6cgiXlVX/YK6G17yn00bKmKkiYuLOAe0RxGtTEEYuGA gjYJClaNGYxtypuUrOW2JQww2tA0GEK0YBVpov1RyoBP4hDwsZDjCuOtKkoAaZQb8XWx7i 98euAmb9sM35tluf2Xs6z7Yd1vktniI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713444085; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U7DjYF/kzJVRyzAMWLo9U8Tt/CvqZCHiGjMu2GCpIDI=; b=wwjPwJkLn9NuL2V4IfPdQnaU2WxlBfx1gurlLfpMq0IUkNcXpZ0viQmf67/jerGBufzDzO 88l9eMsO8Gbuv1DQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Do9eUX88; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wwjPwJkL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713444085; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U7DjYF/kzJVRyzAMWLo9U8Tt/CvqZCHiGjMu2GCpIDI=; b=Do9eUX882YqcS8xoSEeXDPg4XTx6cgiXlVX/YK6G17yn00bKmKkiYuLOAe0RxGtTEEYuGA gjYJClaNGYxtypuUrOW2JQww2tA0GEK0YBVpov1RyoBP4hDwsZDjCuOtKkoAaZQb8XWx7i 98euAmb9sM35tluf2Xs6z7Yd1vktniI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713444085; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U7DjYF/kzJVRyzAMWLo9U8Tt/CvqZCHiGjMu2GCpIDI=; b=wwjPwJkLn9NuL2V4IfPdQnaU2WxlBfx1gurlLfpMq0IUkNcXpZ0viQmf67/jerGBufzDzO 88l9eMsO8Gbuv1DQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 96F5E13687; Thu, 18 Apr 2024 12:41:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iKYuIvQUIWYyfQAAD6G6ig (envelope-from ); Thu, 18 Apr 2024 12:41:24 +0000 Date: Thu, 18 Apr 2024 14:41:23 +0200 From: Oscar Salvador To: Miaohe Lin Cc: akpm@linux-foundation.org, muchun.song@linux.dev, david@redhat.com, vbabka@suse.cz, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when dissolve_free_hugetlb_folio() Message-ID: References: <20240418022000.3524229-1-linmiaohe@huawei.com> <20240418022000.3524229-2-linmiaohe@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FUZZY_BLOCKED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 18E975CA7F X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Score: -4.51 On Thu, Apr 18, 2024 at 04:00:42PM +0800, Miaohe Lin wrote: > On 2024/4/18 12:05, Oscar Salvador wrote: > > On Thu, Apr 18, 2024 at 10:19:59AM +0800, Miaohe Lin wrote: > >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c > >> index 26ab9dfc7d63..1da9a14a5513 100644 > >> --- a/mm/hugetlb.c > >> +++ b/mm/hugetlb.c > >> @@ -1788,7 +1788,8 @@ static void __update_and_free_hugetlb_folio(struct hstate *h, > >> destroy_compound_gigantic_folio(folio, huge_page_order(h)); > >> free_gigantic_folio(folio, huge_page_order(h)); > >> } else { > >> - INIT_LIST_HEAD(&folio->_deferred_list); > >> + if (!folio_test_hugetlb(folio)) > >> + INIT_LIST_HEAD(&folio->_deferred_list); > > > > Ok, it took me a bit to figure this out. > > > > So we basically init __deferred_list when we know that > > folio_put will not end up calling free_huge_folio > > because a previous call to remove_hugetlb_folio has already cleared the > > bit. > > > > Maybe Matthew thought that any folio ending here would not end up in > > free_huge_folio (which is the one fiddling subpool). > > > > I mean, fix looks good because if hugetlb flag is cleared, > > destroy_large_folio will go straight to free_the_page, but the > > whole thing is a bit subtle. > > AFAICS, this is the most straightforward way to fix the issue. Do you have any suggestions > on how to fix this in a more graceful way? Not from the top of my head. Anyway, I have been thinking for a while that this code needs some love, so I will check how this can be untangled. -- Oscar Salvador SUSE Labs