From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 F38EE347C6 for ; Wed, 22 Apr 2026 01:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776822500; cv=none; b=cDakTVBQ8QnMBErE0EQel0O4kyyr80nqUPF2U447bF5WUdFen0J8/h3bgWL0ZxDvhy0tMU8z1UuRwkw3COjLidqw91LoFovqCWMrqzjFtyiYZ2qNpaFXJPetedBVVl9bZKaKtTJWyTho1mf2LFO/N4X7zWDIuViWM/Pw9RCFZTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776822500; c=relaxed/simple; bh=57KgQNA6TjeeAl0+a2XCGkrS3Q9MlgeTPpjIuemXDFQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RWWxA1qAEadW++QDvd+klEz5kRztQpSRI/YMtWFXH8br8A/Q4rphMPL3A8Rv98L+hnHN0K2YTdvY1MYJaR8kenJQOUwi6Oj2OTlCIOrW+9gD1q/dKmK3yNPpIVZxQu9iLSK4QoCL1FJ4HNCmfz1EKAAHH8ejggoOLBJekj1iQa8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=uYYPg5af; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="uYYPg5af" Date: Wed, 22 Apr 2026 09:48:05 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776822495; 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=7Q/C73m2ud1wZ0KXWo0mIOVakWeAibL2+LZFP/oYci4=; b=uYYPg5afRpbDLM6CFdKyq9HrrEUoHCuCx0PeTwqnal5qZbtXXRGw1JWzRC7Vclp9NtjQYt ynT+KgeXxlcRPrZvEWvcd6yn7oSfHHLlRfEzFcaHAzRCXb3qq2iBeCHIZ53RB+C3+p7k3w Pm31zg4DmnUkvkB94MbrrDK1estlRkU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: Chris Li Cc: linux-mm@kvack.org, akpm@linux-foundation.org, usama.arif@linux.dev, baohua@kernel.org, kasong@tencent.com, nphamcs@gmail.com, shikemeng@huaweicloud.com, youngjun.park@lge.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/3] mm/swap: use swap_ops to register swap device's methods Message-ID: References: <20260417033951.1111038-1-baoquan.he@linux.dev> <20260417033951.1111038-3-baoquan.he@linux.dev> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On 04/17/26 at 07:30pm, Chris Li wrote: > On Thu, Apr 16, 2026 at 8:40 PM Baoquan He wrote: ...snip... > > +int init_swap_ops(struct swap_info_struct *sis) > > +{ > > + /* > > + * ->flags can be updated non-atomically, but that will > > + * never affect SWP_FS_OPS, so the data_race is safe. > > + */ > > + if (data_race(sis->flags & SWP_FS_OPS)) > > + sis->ops = &bdev_fs_swap_ops; > > + /* > > + * ->flags can be updated non-atomically, but that will > > + * never affect SWP_SYNCHRONOUS_IO, so the data_race is safe. > > + */ > > + else if (data_race(sis->flags & SWP_SYNCHRONOUS_IO)) > > + sis->ops = &bdev_sync_swap_ops; > > + else > > + sis->ops = &bdev_async_swap_ops; > > + > > + if (!sis->ops || !sis->ops->read_folio || !sis->ops->write_folio) > > + return -1; > Nitpick: > > For int type error return, you should use -EINVAL or some thing with > error code. If you don't care about error code, change the return type > to bool instead. Thanks for careful reviewing, returning -EINVAL looks better, I will change like that and repost. Thanks Baoquan