From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 42CE113B5B3 for ; Fri, 24 Apr 2026 04:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777006062; cv=none; b=DmjYP6q431Vjqb7UTWu/7yInjMJQIdEmtY9D5avIVDwEd3lmUMXfyyGjkK+x0lMTr63qbnFEdg+1OuJTdDH8Kg348EiwOPmvkm+cIwZzidhLDwIwzWNhutD/wVBdmw9jPNXicaJENTKiAWY7GURroYvfZWC9FN9rCsFkaxwkQ/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777006062; c=relaxed/simple; bh=yYy/unFM0RJNbd19Yy/pbBd51ifW45WFM2xDNQ38lsQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L23i5XVM7et4d8hkERSPhSsTts1WDFoEcBfo93iOBHBLEXxr0ClANd3+NvYAy96I9bFil0grjU419wiskUuUpWQ2t1PEphTT9GjlK79QI5w0HXAH7cUhQYtFjlT5/i6+8bXYPw/j/hhcPeSF1Z3XGW85PJND2ylyI5Pp5Qn9h2M= 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=cCeQohvZ; arc=none smtp.client-ip=91.218.175.178 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="cCeQohvZ" Date: Fri, 24 Apr 2026 12:47:28 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777006057; 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=Vh1Lqx2A3VmceNvId69+yEt8g9r8y7I/d6ws2ri6rLU=; b=cCeQohvZeVDF/JEcQf6yh1S/Tx1l1CVvHbnE7+b9EEz7p6czRPKsdhJBkbIzLYy/uZW9ph /5q7SdMnMY+aMvRMgjLNR37IoRRutTsGLLvZpzHZ5/0vMXzb/+Tf1MjCYRP2nOt6/wuFHj /oYRyvlcRCFEFqlYTfVVAn5RfXipXLI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: Chris Li Cc: akpm@linux-foundation.org, linux-mm@kvack.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/23/26 at 02:48pm, Chris Li wrote: > The incremental change code logic looks fine. > > On Wed, Apr 22, 2026 at 7:37 PM Baoquan He wrote: > > > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > index af81fa212f1e..7644049a0919 100644 > > --- a/mm/swapfile.c > > +++ b/mm/swapfile.c > > @@ -3518,10 +3518,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > > goto bad_swap_unlock_inode; > > } > > > > - if (init_swap_ops(si)) { > > - error = -EINVAL; > > + if (error = init_swap_ops(si)) > > Some more nitpicks: > > I think some compiler option might warn about assigning a variable > inside an if condition. I suggest moving the assignment outside of the > if condition expression. As it is, it looks very close to "error == > init_swap_ops(si))", Some compiler might warn, "Is that what you mean > instead?" I personally prefer the one doing assignment inside if condition expression because it is a ittle neater with one less line. While it doesn't matter much. Here comes the new version of the incremental update. Thanks. diff --git a/mm/swap_io.c b/mm/swap_io.c index 77aa8373c087..e2710d5fb44e 100644 --- a/mm/swap_io.c +++ b/mm/swap_io.c @@ -625,7 +625,7 @@ int init_swap_ops(struct swap_info_struct *sis) sis->ops = &bdev_async_swap_ops; if (!sis->ops || !sis->ops->read_folio || !sis->ops->write_folio) - return -1; + return -EINVAL; return 0; } diff --git a/mm/swapfile.c b/mm/swapfile.c index af81fa212f1e..82d2c9b35b11 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3518,10 +3518,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) goto bad_swap_unlock_inode; } - if (init_swap_ops(si)) { - error = -EINVAL; + error = init_swap_ops(si); + if (error) goto bad_swap_unlock_inode; - } si->max = maxpages; si->pages = maxpages - 1;