Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp198355lqt; Thu, 6 Jun 2024 00:21:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7rGIr3Uh8Auabf0Ntdo6CQ5Y2t5FiLYrphvis/POIopzPvzljjZO+GPYkeMdVmc1OIbFI7rvq6tE2XyY6wcmHRYnVT7+cMZCZMcMqgA== X-Google-Smtp-Source: AGHT+IEcn36aORIQ9TFbBCAdqLUxc9VI6UffJsBTuFh2rddKnfB6xiHPwrY6HrjqwlNnrmqNFnmc X-Received: by 2002:ac8:5e08:0:b0:43e:3bc9:b5f2 with SMTP id d75a77b69052e-4402b688419mr45117991cf.64.1717658517759; Thu, 06 Jun 2024 00:21:57 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038b5fe9bsi8902891cf.529.2024.06.06.00.21.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=KQBX9XHR; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-203724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F2A41C24603 for ; Thu, 6 Jun 2024 07:21:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DB4F13AA42; Thu, 6 Jun 2024 07:21:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="KQBX9XHR" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2044.outbound.protection.outlook.com [40.107.117.44]) (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 788143BB59; Thu, 6 Jun 2024 07:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.44 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717658511; cv=fail; b=ia7kyykE0NaEHRm9SWYQjbcD/7YODd9NT5Fsi5bRePKxNYjUk+VvRLhisppeeGJ0H584z9qTpZLa/AeA8CVw2SZS0/z7M6VSwJavRFrowZ2t2ubKg7kARuty6SFeyR7VvCHJ0cslZEVsVvLh+CCX1iPARxeAuNKXtV7CDscofKU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717658511; c=relaxed/simple; bh=nEmkXwidkj7Kan1tDQQF7TtfbfiXOEe1hNW7Lp+HxtE=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=WNCOxfOnLsFsWGsSBZfbSHznYdfpK7+thxKwmO7PO+aWgw1a5Otg2wt5GpSvMaxwsFg63GavaZRlwSUWhxLpawccgkBb/W7KO/kSRxjPNJyH0+Euj3i9T9HmNkU8g6oMJfvjaYqgV+de3FBGCILgUkJDeL6q/acNK4AYt1xtXaM= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=KQBX9XHR; arc=fail smtp.client-ip=40.107.117.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LFA+PZ70PfVXShvip8lsb9exZwew+yw+s/3n3jzZXhumiewA3GILvv+ANQCDPpihzMtnb7gOAt8bo2Hg3dyb9tbHxsZWpsNlBwwfL6qve/MMlm/OADuznDGa1yhLDhqYZPABtOV11XQFkwr/4G9WGpTdDJ/HOu2bO7/fytlVwc/fpasqhU4iTXimiFmitJSNXShVIiwyJJpe8hGJ2Uh8EZbWtTv5LPxEOY2CKeyRsZHV6lNPzjgNc/b0pz5AYv3nJuTPy8EN5BwXLao6gPtpiAizm1Mn6HfyJpkHJvMvTnSONZVIQjW7L3eP1xDA5+lGG1gXh0BCINvx7O1IjBxG5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AgDXFrdqJ5YP+iWw9OCZwshGbhYMneitzjdUMEDtczY=; b=kicrJNU9U25sINGLTNC1MgEuYVZ64gHXElkRtQAkWsnCK+6eaPk2N9MqClUb11KSqauhzisdA3xzQRbba5+yTpYLNJE/4nf0pox6PPNJ4bt7FMCaNuTX9PZOHi06zgcpKPKAjAZCVgYKb8dc13QOc6IPAjY0fcZlFLJ9YZLfiuutvHSeKhsxn9712zg8pplbyOCoxD3HK3VJsd4C2zcUOBCE0hKLp0tzm8q4RC4yGpR3gzo5Wtr5iaGVa8TuN/TIkIJrkeLQ7b+6N180dE29MNzAjRxQG5i2Nlkg7p4v41w9JwrvthaGYFgUDrYpoZbIYkI1b6nHVlux1k6r15MJ+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AgDXFrdqJ5YP+iWw9OCZwshGbhYMneitzjdUMEDtczY=; b=KQBX9XHRiQSRYIk0uK6CRdIi3MOvgynsxekFAQczDXy/nfmn1bKiCxucIKt2bmgvAg3oueirKNtlCXkq6igOVVK540B+KuBWb1XWcv0le0FOxdTTVuCuK12ru/7wg7f5iH/uOjpeX7hdvRcU7D9XaFzIJBU0KO02YxgWpT6ywNdxTwtERElIce8Cr54bPqrpiSg2aeb78aqxcyY6GtCQiwbHT/9UO9Ab3kaanUqSCTDdkgWhxJctYAMdVpEwPdSXZfIYSfjESMagwA1IffNC0q5E524hjEYGMKkJppHlOB5gbHOEh8SbacLUM+GPIkFj3cEOQ4kRgtVGjpEyvvklFQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from KL1PR06MB7401.apcprd06.prod.outlook.com (2603:1096:820:146::12) by TYSPR06MB6504.apcprd06.prod.outlook.com (2603:1096:400:477::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Thu, 6 Jun 2024 07:21:44 +0000 Received: from KL1PR06MB7401.apcprd06.prod.outlook.com ([fe80::f4f:43c4:25e5:394e]) by KL1PR06MB7401.apcprd06.prod.outlook.com ([fe80::f4f:43c4:25e5:394e%4]) with mapi id 15.20.7633.033; Thu, 6 Jun 2024 07:21:43 +0000 Message-ID: Date: Thu, 6 Jun 2024 15:21:38 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] sbitmap: fix io hung due to race on sbitmap_word::cleared Content-Language: en-US To: Ming Lei Cc: Jens Axboe , Andrew Morton , Pavel Begunkov , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, "yukuai (C)" , Yu Kuai References: <20240604031124.2261-1-yang.yang@vivo.com> From: YangYang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: TYWPR01CA0016.jpnprd01.prod.outlook.com (2603:1096:400:a9::21) To KL1PR06MB7401.apcprd06.prod.outlook.com (2603:1096:820:146::12) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR06MB7401:EE_|TYSPR06MB6504:EE_ X-MS-Office365-Filtering-Correlation-Id: f9e486e2-e029-4cc3-b087-08dc85f9512c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?cEdhSEluc2tJelZPY01JWjFod1BwbTJOcWJvV3RlSU9XQmxaaGZ5cVkzTm9o?= =?utf-8?B?KzNpbmpRODEvaU5kVWJLZE5MbHNrNmRvc0ZhWDNERjkrV09BMXFPdHA4YVM2?= =?utf-8?B?Z3RyTHhJSXF4WG8rNi96ZUtxaWF5VGxlTTlKaEI3S2s1d0FLUGcrbjlibFFP?= =?utf-8?B?S2VJZURXb3AwVzh2amNDcW4yR1lPaHdLVFRZVVlTYzVEc1B3TnRmN0RRN1Iy?= =?utf-8?B?YS9pV1RUbTVucUNJa3k2R0xMbEJwMG9DelV1cTFJMUR4dDNjSjF0Zkk1cjE0?= =?utf-8?B?dmQ3WUtxNFA4NUcrVlExMENSdnJleG5aRDc5YTRFWHZjZlhqUzQrVENaTkhF?=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txOVQ4cC9j?= =?utf-8?B?dU4zM1pOWStZbUVJZVpTUGxNY2c4VWNlclVVUEwySk1jUGVjQlBPWEdyU0g1?= =?utf-8?B?NFlremxNMXZUcndDOFY4SjVLNUtSaUxraFhKNzQ4aVI2S1Nod21QbkNWcTc5?= =?utf-8?B?bThOZnY1YWhmY0U1czJrUU0xS2x2VjlnZUN0UEhnU2tLWENmSjdzSThwSXVI?= =?utf-8?B?Y0kvZTd6Uk1JV2NZMEhQS2R1Q0VhOE1zMXlOTExWcDVCYnkzd3VxSjFEM29R?= =?utf-8?B?VlM1b2d0dU95bzBGa1pIMFpENzRkaEhRem1TcWJadzdtRWlldG9lMlhNR3VI?= =?utf-8?B?dXRRS2txMHQ1RlJDSWJFS1RDN1ZXN0tZZHA3a2pwekRXQUtCbmlPQ1cwSEJy?= =?utf-8?B?bmJHNXpKQlBaZUU4SWhKRFZNdVEvcUlERm1WcDg2NjdQR3QxUEdzZm5mbWh5?= =?utf-8?B?anBDNDJ5U3QrYk14bk9RMmpHblRqM2JyekFXK0dsVzl5VitmMkYyZTR3OEFi?= =?utf-8?Q?nkH1RvbaZAR7YOE62IiZni/JraAjns/9alcXX1p?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:KL1PR06MB7401.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YkJrQVRYd2FKd1hPTnoxZzlUdDAwcUczbitaUmRMNWo3UWluL2EvOGFFMWox?= =?utf-8?B?bkpPWHc4d3g5c0I2eHJnakd4bFo2c3FkS1JudXl1VWNablF2M2R6dmh0dkpR?= =?utf-8?B?bVM2alFRZmw1TUl6RWxNeFVadmlGM2cyUXp6cldCTXozSkI1SFhtcXpkVmNv?= =?utf-8?B?bG95e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yd2I2bXUzSmVz?= =?utf-8?B?UHlod3NtMk5wU1huZ0s2T2hiY1NrQ1NSMi8vODJUMG1Hc2NpTUFmSXQ1QXY2?= =?utf-8?B?MVRyeTJFWExDbEhOM0Eydm9NbVV1K3hwdUFtSVRTS0lNYnY1bGNJZ3M2eEZT?= =?utf-8?Q?jjtPI3rsDJCGjruE+f2HVZ2gA?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9e486e2-e029-4cc3-b087-08dc85f9512c X-MS-Exchange-CrossTenant-AuthSource: KL1PR06MB7401.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 07:21:43.6624 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HklFFXkwknK0Ef5I7K/Psa0PS8NAf376kyIqM82+NATWZSTjczs+29yFtCBcEEz7+vHrvRu9ZJxXN+DsBYyR4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR06MB6504 On 2024/6/6 11:12, Ming Lei wrote: > On Tue, Jun 04, 2024 at 02:12:22PM +0800, Yu Kuai wrote: >> Hi, >> >> 在 2024/06/04 11:25, Ming Lei 写道: >>> On Tue, Jun 4, 2024 at 11:12 AM Yang Yang wrote: >>>> >>>> Configuration for sbq: >>>> depth=64, wake_batch=6, shift=6, map_nr=1 >>>> >>>> 1. There are 64 requests in progress: >>>> map->word = 0xFFFFFFFFFFFFFFFF >>>> 2. After all the 64 requests complete, and no more requests come: >>>> map->word = 0xFFFFFFFFFFFFFFFF, map->cleared = 0xFFFFFFFFFFFFFFFF >>>> 3. Now two tasks try to allocate requests: >>>> T1: T2: >>>> __blk_mq_get_tag . >>>> __sbitmap_queue_get . >>>> sbitmap_get . >>>> sbitmap_find_bit . >>>> sbitmap_find_bit_in_word . >>>> __sbitmap_get_word -> nr=-1 __blk_mq_get_tag >>>> sbitmap_deferred_clear __sbitmap_queue_get >>>> /* map->cleared=0xFFFFFFFFFFFFFFFF */ sbitmap_find_bit >>>> if (!READ_ONCE(map->cleared)) sbitmap_find_bit_in_word >>>> return false; __sbitmap_get_word -> nr=-1 >>>> mask = xchg(&map->cleared, 0) sbitmap_deferred_clear >>>> atomic_long_andnot() /* map->cleared=0 */ >>>> if (!(map->cleared)) >>>> return false; >>>> /* >>>> * map->cleared is cleared by T1 >>>> * T2 fail to acquire the tag >>>> */ >>>> >>>> 4. T2 is the sole tag waiter. When T1 puts the tag, T2 cannot be woken >>>> up due to the wake_batch being set at 6. If no more requests come, T1 >>>> will wait here indefinitely. >>>> >>>> To fix this issue, simply revert commit 661d4f55a794 ("sbitmap: >>>> remove swap_lock"), which causes this issue. >>> >>> I'd suggest to add the following words in commit log: >>> >>> Check on ->cleared and update on both ->cleared and ->word need to be >>> done atomically, and using spinlock could be the simplest solution. >>> >>> Otherwise, the patch looks fine for me. >> >> Maybe I'm noob, but I'm confused how can this fix the problem, looks >> like the race condition doesn't change. >> >> In sbitmap_find_bit_in_word: >> >> 1) __sbitmap_get_word read word; >> 2) sbitmap_deferred_clear clear cleared; >> 3) sbitmap_deferred_clear update word; >> >> 2) and 3) are done atomically while 1) can still concurrent with 3): > > After 1) fails, sbitmap_deferred_clear() is called with spinlock, > then it is pretty easy to solve the race, such as, the following patch > against the revert patch. > > > diff --git a/lib/sbitmap.c b/lib/sbitmap.c > index dee02a0266a6..c015ecd8e10e 100644 > --- a/lib/sbitmap.c > +++ b/lib/sbitmap.c > @@ -63,13 +63,15 @@ static inline void update_alloc_hint_after_get(struct sbitmap *sb, > static inline bool sbitmap_deferred_clear(struct sbitmap_word *map) > { > unsigned long mask; > - bool ret = false; > unsigned long flags; > + bool ret; > > spin_lock_irqsave(&map->swap_lock, flags); > > - if (!map->cleared) > + if (!map->cleared) { > + ret = !!map->word; After atomic_long_andnot(mask, (atomic_long_t *)&map->word), map->word may be 0 if all requests have completed, or not 0 if some requests are still in flight. Therefore, using !!map->word to determine the availability of free tags is inaccurate. Thanks > goto out_unlock; > + } > > /* > * First get a stable cleared mask, setting the old mask to 0. > > > Thanks, > Ming >