Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp688876lqa; Sat, 27 Apr 2024 22:46:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKN5Z7xYUns9rAJs+KPwIeuRw2lwlw5a1cwoZlcRntsH1sG2YSiNM4hXr8Ek4aGzYrybkdsYqB6HhBSh0vr7XSJJbciNo5n1XQplFaGQ== X-Google-Smtp-Source: AGHT+IHu8vmdTKVYR1j/BkAx1b/ZYprODzj8y7xnEGDu2JknjSyVl+BSu8pqiiH8Ac3gQawk4tLP X-Received: by 2002:a50:8a89:0:b0:56c:d35:1775 with SMTP id j9-20020a508a89000000b0056c0d351775mr5986987edj.35.1714283211086; Sat, 27 Apr 2024 22:46:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714283211; cv=pass; d=google.com; s=arc-20160816; b=tK1+R0c73Qqdj1Fpo4nWUcvoMg3v7D+v6UrYBDOMUYdtIt6UO/olzX32XIOpG5WS4U gWL9bDbKnOe2Jk86auefOZiefS38yfAhYlJ9pCNHxVv/hoKmnR3ldgpCMSV1wkT57+Q+ Hh7Q21EkAZMHjvV7dTsPex8HADw702fXbbil4BrvUOyj0gF8wg6N6i/76zXHPDAmtj8p tQEjSRSw6QJR+xsr7/9raO1lY1Cb05h/5t+4Y7gnW+9qkFLWwwwPMW8xASs67beD//oh Mf9uUxya1q67cXqAPc4tjUhaO+Sz76bGh3LKVBv4Qbi+1/EUc3T8f1EO0+zS8eqmaQ0/ zfUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=iEhnO4AWXoNxFsAFeSCOgVl/u1tIJg7C/6bLYFJsfso=; fh=Mg9RlSfejr6eEZ8ZZs4gE3L0oAyfBuvsZOsTfyh/B30=; b=aBO2/dljDPvjm+aUWkHOahliU1zxn4+EEJPeDDdVOqE0JFsqjwuOxDsrLX6A12+Bee KBvtzJLYZWV2wNNkBrRUrmOvtSpKGVDuzpidW50Fp0Jk8CW4OPOw1XBz/z2iGDhZXlip 0fkJhLS5z7IaN8P2f2U2fhgzWG6cLbAKQSbGq0Yc8r91yLk6Ibhstf5uBZtBbnXLdsbu LpiJR1wxBta0/rrA6YbZYvaPrbAkx7pXh04NBC/TTB8wisfwTjUL8bsRUpeMH/bITPCE FmTsa0CbLV8EKRpdnmDhje2GkMi69nJE3MFVxtkf9g0lAdkjx+1uwzDErfmogyAd9t1F YzNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=IWHqDCYU; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-161203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n2-20020a056402514200b0056c3b60243bsi12357086edd.308.2024.04.27.22.46.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 22:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=IWHqDCYU; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-161203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 01B0D1F2170D for ; Sun, 28 Apr 2024 00:57:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9CB3110A; Sun, 28 Apr 2024 00:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="IWHqDCYU" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 758067E1; Sun, 28 Apr 2024 00:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714265848; cv=none; b=cog7h0mayUNiy74bCCewoqZKCwaKH6d/MOtgEPlT9kQxgOor0SkrnAqR13RNsyijiqmJdRWuvnTMHXjNqetCPfSY8KXW8n6sHoL95EoWPlRJq22uPMIY8iuqRQukdIA2G1ltX3lo/6Wwol+mUEhr5svaMDOkMnABPfRgDOgGSAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714265848; c=relaxed/simple; bh=54uIGKbchIqeyGHCinmigs69p/bVqpwlPIcL4lKukpQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uonBy4nHXkFcmUKnQcq79r86Pm3L9ZoB9gyNuX2KMUniWp4vCuyqqSa5HTGDPaHNYsszm8QiuH6qGFpfFqsHG4fw+QBsTF4I/tN/dTbTUyjyfqKKKkr92xEhC6MSCEmv9HfynDqc6/CT9bU3Xw2oYeq0y/WICxWi8yJfZ0Otpn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=IWHqDCYU; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iEhnO4AWXoNxFsAFeSCOgVl/u1tIJg7C/6bLYFJsfso=; b=IWHqDCYUczIV+YtqAUlL6HVU+V qCtZyJpY5Sh2NfLpSQK0jlGyEtErUphjfxsjrprhsLPjB+PmckQ17consJv5VugT5B64CyFQ3dIAD WajK1Il7ARNNEV/N8P0Mb0R5DHCFMJoAMKyWI7Qmz4Lu6MNnDpgneBWjCEKZoSN8OpO1PbghXkg+c vrs8MDYIDAUlKDlpojo4H5DPbN0R8m6m/6qvwBnplNJ9p4Lm03LOOuvj5k846ad5o1rV/sczirBif P5BktIszYYw7GDr4ZqNSZVwKat58sz1tf2UdKbpR4DrowlURDVSud5kA9E9EvWWc+Q5LmyKtpUtoW wy8sUNtw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0sqz-0000000GWGt-1oqf; Sun, 28 Apr 2024 00:57:17 +0000 Date: Sat, 27 Apr 2024 17:57:17 -0700 From: Luis Chamberlain To: Matthew Wilcox , ziy@nvidia.com Cc: "Pankaj Raghav (Samsung)" , djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: Re: [PATCH v4 05/11] mm: do not split a folio if it has minimum folio order requirement Message-ID: References: <20240425113746.335530-1-kernel@pankajraghav.com> <20240425113746.335530-6-kernel@pankajraghav.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: Sender: Luis Chamberlain On Fri, Apr 26, 2024 at 04:46:11PM -0700, Luis Chamberlain wrote: > On Thu, Apr 25, 2024 at 05:47:28PM -0700, Luis Chamberlain wrote: > > On Thu, Apr 25, 2024 at 09:10:16PM +0100, Matthew Wilcox wrote: > > > On Thu, Apr 25, 2024 at 01:37:40PM +0200, Pankaj Raghav (Samsung) wrote: > > > > From: Pankaj Raghav > > > > > > > > using that API for LBS is resulting in an NULL ptr dereference > > > > error in the writeback path [1]. > > > > > > > > [1] https://gist.github.com/mcgrof/d12f586ec6ebe32b2472b5d634c397df > > > > > > How would I go about reproducing this? Well so the below fixes this but I am not sure if this is correct. folio_mark_dirty() at least says that a folio should not be truncated while its running. I am not sure if we should try to split folios then even though we check for writeback once. truncate_inode_partial_folio() will folio_wait_writeback() but it will split_folio() before checking for claiming to fail to truncate with folio_test_dirty(). But since the folio is locked its not clear why this should be possible. diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 83955362d41c..90195506211a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3058,7 +3058,7 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, if (new_order >= folio_order(folio)) return -EINVAL; - if (folio_test_writeback(folio)) + if (folio_test_dirty(folio) || folio_test_writeback(folio)) return -EBUSY; if (!folio_test_anon(folio)) {