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 ED7D3C021B8 for ; Tue, 4 Mar 2025 12:09:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 668856B008A; Tue, 4 Mar 2025 07:09:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 618906B0092; Tue, 4 Mar 2025 07:09:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E08B6B0093; Tue, 4 Mar 2025 07:09:43 -0500 (EST) 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 2F70B6B008A for ; Tue, 4 Mar 2025 07:09:43 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D29231CBBAC for ; Tue, 4 Mar 2025 12:09:42 +0000 (UTC) X-FDA: 83183749404.19.69E5564 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id 30AC240004 for ; Tue, 4 Mar 2025 12:09:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741090181; 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; bh=lBRBsItctluqrWPxWxS5Cy+uZ15rzHg6NKLZTj2x0FA=; b=O6ruqjl2Xq328ym3i/se6UiGm/ovFT2Kktd/NqjKs1zjOAJnfn/QlZU+J2qU8YGoFYmPOw N9ccdV0KDUfj/GxhVHNejISUNVbJvgD3Y306jGgGhASIyEfhL4w2K1Xp+yYI4nGP8jBoJK aAbc3iCnjYd05DG/xQmb7WQoz37apSc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741090181; a=rsa-sha256; cv=none; b=jEH13QA6jbKPftl7GQh59h/+bHV9txfPh1AJxNZbP5/yUBQRL/Zk7W1AaqupfzoWLMyBNA yeND69frG+klARO47BsphQwbsaOIeV3yE5/+gnAe1WSmiUPuc7iTdpK8IpOMUB6xJWPM7X cknSct0BOw+9NbTCgVGe6BcHQx7d+o0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Z6ZBX3494z2DkHc; Tue, 4 Mar 2025 20:05:24 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id D7E721A016C; Tue, 4 Mar 2025 20:09:35 +0800 (CST) Received: from [10.67.120.129] (10.67.120.129) by dggpemf200006.china.huawei.com (7.185.36.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 4 Mar 2025 20:09:35 +0800 Message-ID: <91fcdfca-3e7b-417c-ab26-7d5e37853431@huawei.com> Date: Tue, 4 Mar 2025 20:09:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm: alloc_pages_bulk: remove assumption of populating only NULL elements To: Dave Chinner CC: Yishai Hadas , Jason Gunthorpe , Shameer Kolothum , Kevin Tian , Alex Williamson , Chris Mason , Josef Bacik , David Sterba , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Sandeep Dhavale , Carlos Maiolino , "Darrick J. Wong" , Andrew Morton , Jesper Dangaard Brouer , Ilias Apalodimas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Luiz Capitulino , Mel Gorman , , , , , , , , , References: <20250228094424.757465-1-linyunsheng@huawei.com> Content-Language: en-US From: Yunsheng Lin In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.120.129] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspamd-Server: rspam02 X-Stat-Signature: 9o1dycf191w7ba9hpboedtojysmtr4pr X-Rspamd-Queue-Id: 30AC240004 X-Rspam-User: X-HE-Tag: 1741090179-341731 X-HE-Meta: U2FsdGVkX19eeoQJWokV8kGaNTch/KII1yGiWD3mMF7MoEHY0K71wHjuZjaFO7qAt3hS59YhcnSOE6GbTRU9dvT1dOZcw/7+o3ms1PoG00s72E6RJHxcC5Y10rJDLGKz0sJOnzExTLwgfNfOu9gX9QtgQy7MZQinhGzNFULeP/zf/RBTBxMzcRmzeMRUQc5X1p9xf4VH2RuaVvDvNbS5t9SQjzXz3ilg22inqcnzjXdP2reAa2ia9YpXqvIgH2bN4BLZshp+sE6e3hId7dTpFOqc3j6etaSt9Os3g8//CXfhCUXg8VDavSrdfFJ0gCDJtnNKUBL9kRXh9kxMLshVpWZshrk2BZGubPTuMEqXr0c3x0d0tmZirz7TEA0ZHYIuPBWPQmgfWIV+vPs7UGsUdgPOnYV2VC0K/esmHFhrWaZGSuiqDklR9vtTkUeBAJ+uvr2maIkG4yPZ2ZlBr4hgHPI7E5RHifvmWT8Oh2Ua6oBZCXgjkHfInBdENCVDj7KorxBueYdK+Q7LcLLcqWVIJtdg8dtWeczVhh3SYlnl5cuhLFwYKClvXitj7y5iMZI1O4NPGSlgKln++au5AjtrbVktdyaLB5cUEW06REi6HpN4TU9Y6rEg8pXXDgu36le8bAP/Oel/dmQitb68oJgk0uX8IH846T3XJSHKEJ2q+ct/iGO1E77Rukb8tIQNkBsUtlb1QPFBD2Os+xQGn1gC+9dGubDHKR4oYYhbi9BY13OM1ArM0T/upj6EuYIHnzIZNDgcqAfHP41HB6lwHIzI/pLp761RZxBf6i43viQagaAjY0qqas58mCrHlCxLZREE9iRthOz13I2bjaWXGiWDLCCrrCHJjuiIFexIUeEj2QDv6ZZIGKq8SjRzRuXzb5gE68E4KU8imd4oczJhJSLshTHNLsp1bTnHqNB6POeCMWfmKgnKTa3f0Isht0aCEwUlwIisVRd4BiUolzK//mT pjUq7+t1 JG6H5otQYhTZ1sndMZByxNZ9OSayXVbp3nWHEvlkAyOsphj2H+Zrdv2F1jFryvGAGFSXXuYe25JkTy1RWjtkdHuSn7EJqFTJII/8etMjsV5yHNwDYzE2v2q1V+5QTp9wpT2JWwhkN4pcmQLr0fosvLSHeC7i5A42LEyp0/Wi87JnNF8wCfqs4/RjeC3gVFAYWBNoX2uy8k2AOqVAeEl/zjoeyoqRkeAEtYhesEhGkhU1fkSRuHj+4M/Ovez1nLlmShIHmB2L+bWaRs7Erh2qJnedu7snuxvBSkJKy/1qaKv06yCE8noyXasy8x+LNwBIaHXvYa/qUB15AZ/1s2j4Y7eaailUmuebCU0pMBr6OD9Dhp0ZZECXFLGkF3j2vSuTtDvDcXuo3BO1iQmRywwhpqjYxDA6uasxhHyYI/8EloxmNG5FEGY/r2Bch9w== 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: On 2025/3/4 16:18, Dave Chinner wrote: ... > >> >> 1. https://lore.kernel.org/all/bd8c2f5c-464d-44ab-b607-390a87ea4cd5@huawei.com/ >> 2. https://lore.kernel.org/all/20250212092552.1779679-1-linyunsheng@huawei.com/ >> CC: Jesper Dangaard Brouer >> CC: Luiz Capitulino >> CC: Mel Gorman >> CC: Dave Chinner >> CC: Chuck Lever >> Signed-off-by: Yunsheng Lin >> Acked-by: Jeff Layton >> --- >> V2: >> 1. Drop RFC tag and rebased on latest linux-next. >> 2. Fix a compile error for xfs. > > And you still haven't tested the code changes to XFS, because > this patch is also broken. I tested XFS using the below cmd and testcase, testing seems to be working fine, or am I missing something obvious here as I am not realy familiar with fs subsystem yet: Step to setup the xfs: dd if=/dev/zero of=xfs_image bs=1M count=1024 losetup -f xfs_image losetup -a ./mkfs.xfs /dev/loop0 mkdir xfs_test mount /dev/loop0 xfs_test/ Test shell file: #!/bin/bash # Configuration parameters DIR="/home/xfs_test" # Directory to perform file operations FILE_COUNT=100 # Maximum number of files to create in each loop MAX_FILE_SIZE=1024 # Maximum file size in KB MIN_FILE_SIZE=10 # Minimum file size in KB OPERATIONS=10 # Number of create/delete operations per loop TOTAL_RUNS=10000 # Total number of loops to run # Check if the directory exists if [ ! -d "$DIR" ]; then echo "Directory $DIR does not exist. Please create the directory first!" exit 1 fi echo "Starting file system test on: $DIR" for ((run=1; run<=TOTAL_RUNS; run++)); do echo "Run $run of $TOTAL_RUNS" # Randomly create files for ((i=1; i<=OPERATIONS; i++)); do # Generate a random file size between MIN_FILE_SIZE and MAX_FILE_SIZE (in KB) FILE_SIZE=$((RANDOM % (MAX_FILE_SIZE - MIN_FILE_SIZE + 1) + MIN_FILE_SIZE)) # Generate a unique file name using timestamp and random number FILE_NAME="$DIR/file_$(date +%s)_$RANDOM" # Create a file with random content dd if=/dev/urandom of="$FILE_NAME" bs=1K count=$FILE_SIZE &>/dev/null echo "Created file: $FILE_NAME, Size: $FILE_SIZE KB" done # Randomly delete files for ((i=1; i<=OPERATIONS; i++)); do # List all files in the directory FILE_LIST=($(ls $DIR)) # Check if there are any files to delete if [ ${#FILE_LIST[@]} -gt 0 ]; then # Randomly select a file to delete RANDOM_FILE=${FILE_LIST[$RANDOM % ${#FILE_LIST[@]}]} rm -f "$DIR/$RANDOM_FILE" echo "Deleted file: $DIR/$RANDOM_FILE" fi done echo "Completed run $run" done echo "Test completed!" > >> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c >> index 5d560e9073f4..b4e95b2dd0f0 100644 >> --- a/fs/xfs/xfs_buf.c >> +++ b/fs/xfs/xfs_buf.c >> @@ -319,16 +319,17 @@ xfs_buf_alloc_pages( >> * least one extra page. >> */ >> for (;;) { >> - long last = filled; >> + long alloc; >> >> - filled = alloc_pages_bulk(gfp_mask, bp->b_page_count, >> - bp->b_pages); >> + alloc = alloc_pages_bulk(gfp_mask, bp->b_page_count - filled, >> + bp->b_pages + filled); >> + filled += alloc; >> if (filled == bp->b_page_count) { >> XFS_STATS_INC(bp->b_mount, xb_page_found); >> break; >> } >> >> - if (filled != last) >> + if (alloc) >> continue; > > alloc_pages_bulk() now returns the number of pages allocated in the > array. So if we ask for 4 pages, then get 2, filled is now 2. Then > we loop, ask for another 2 pages, get those two pages and it returns > 4. Now filled is 6, and we continue. It will be returning 2 instead of 4 for the second loop if I understand it correctly as 'bp->b_pages + filled' and 'bp->b_page_count - filled' is passing to alloc_pages_bulk() API now. > > Now we ask alloc_pages_bulk() for -2 pages, which returns 4 pages... > > Worse behaviour: second time around, no page allocation succeeds > so it returns 2 pages. Filled is now 4, which is the number of pages > we need, so we break out of the loop with only 2 pages allocated. > There's about to be kernel crashes occur..... > > Once is a mistake, twice is compeltely unacceptable. When XFS stops > using alloc_pages_bulk (probably 6.15) I won't care anymore. But > until then, please stop trying to change this code. > > NACK. > > -Dave.