From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 20894824A3 for ; Wed, 8 Apr 2026 06:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775628675; cv=none; b=nouSXY6C6H93qCVX22ItdhcaVcHNFOLHLz459oA/t5Juli45plcy1uvNbEBoIO+l9e59VztKUMpkgVo1AF2K4MAH+EhCUUFvM1M0o4Ge/mAbdD1wNSVpkyUPerW81BKxfjGQUTSVAottUwSRkT7wd/SPeIeAATGvEtrWLyX7ud4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775628675; c=relaxed/simple; bh=NtAS5KSgRccjPA9zcusliqS8oTU/G3sEpskfMh6txCc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I9MCCaNddXSrvFzdV/MblnkjoR5YclyNYHKlK199WzVy+142S7NMcndreluSFRSOuhWdSbQ3UKKfjMje3yCo7A5QfCBq0Z6k1NOjgwS6BHfc2apXDF1Ftc6LPNzUCoW4DaVCKCXICPzlqrCxRmpNVggXtU5jVl8xg/WZbDHMLPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pe8BGfNw; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pe8BGfNw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775628673; 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: in-reply-to:in-reply-to:references:references; bh=Nlu9QF2694z5eIp7NFOSYWjTzeADANSAS/DFq4widxs=; b=Pe8BGfNwEWeRECy03D6tPjrDuyqa46uzbOJCoJJ1e0d3a124AOZ4vDRckdIBVCyA58iTgS y5ONqeJweEtkewhzB9uyjv2Oum+U/DPDR6UruV0tYMYe+JajJFLV8WuzhIrVuX+DezcVsD 5ALUUSp45/N+yrtkbmRJm7n2Srmt+Ks= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-170-4Sjs1-YKO3-Ff6kAJSAQUA-1; Wed, 08 Apr 2026 02:11:08 -0400 X-MC-Unique: 4Sjs1-YKO3-Ff6kAJSAQUA-1 X-Mimecast-MFC-AGG-ID: 4Sjs1-YKO3-Ff6kAJSAQUA_1775628667 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8206F1800345; Wed, 8 Apr 2026 06:11:06 +0000 (UTC) Received: from localhost (unknown [10.72.112.14]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0B2951953944; Wed, 8 Apr 2026 06:11:04 +0000 (UTC) Date: Wed, 8 Apr 2026 14:11:00 +0800 From: Baoquan He To: Chris Li Cc: Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org, baohua@kernel.org, kasong@tencent.com, nphamcs@gmail.com, shikemeng@huaweicloud.com, youngjun.park@lge.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] mm/swap: use swap_ops to register swap device's methods Message-ID: References: <20260328075812.11060-1-21cnbao@gmail.com> <20260328075812.11060-3-21cnbao@gmail.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-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 03/30/26 at 08:30pm, Chris Li wrote: ...... > > @@ -608,6 +593,39 @@ static void swap_read_folio_bdev_async(struct folio *folio, > > submit_bio(bio); > > } > > > > +static const struct swap_ops bdev_fs_swap_ops = { > > + .read_folio = swap_read_folio_fs, > > + .write_folio = swap_writepage_fs, > > +}; > > + > > +static const struct swap_ops bdev_sync_swap_ops = { > > + .read_folio = swap_read_folio_bdev_sync, > > + .write_folio = swap_writepage_bdev_sync, > > +}; > > + > > +static const struct swap_ops bdev_async_swap_ops = { > > + .read_folio = swap_read_folio_bdev_async, > > + .write_folio = swap_writepage_bdev_async, > > +}; > > + > > +void setup_swap_ops(struct swap_info_struct *sis) > > setup_swap_ops()` needs to return an indication of an error. > The error is that sis->ops is NULL or op->read_folio == NULL or > op->write_folio == NULL. > If there is an error, we should fail the swapon. Thanks for your comments. In the current patches, there's no chance any of these happens: sis->ops is NULL or op->read_folio == NULL or op->write_folio == NULL Because it's a if-else logic in setup_swap_ops(), adding an error checking looks a little weird. I think it's worth adding the error checking in setup_swap_ops() later when we have new swap_ops added and there's potential any of above three cases could happen. What do you think? Thanks Baoquan