From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86E0438B7A3 for ; Thu, 19 Mar 2026 03:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773890677; cv=none; b=iQ9W4cjLFWKBV7yeahz+ROH8gdW6dPiktPOuXvRyeV4tRVsEMQ2V2ZE9lTLtYJ8x+62x8FlBw6TJIQhEWSki6HZO2s9JHT4J4izT80GdgMRovMVBmslsANQwvNi21MVgvmaKDnv1XXbpDs+z1A7dVexurAG9qUDoZJzcU1+FFoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773890677; c=relaxed/simple; bh=4+mkFfkUAdJb6vud/iWAGN/md0wlqqSyMg3jEam36xc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JHA0GCABJ5eGQgR9+yDH1aL00YIgaz7fLkZhKxHnFdEfCdENi9SXllxxFgXyKlY931SjT7bkrKbrXFnyV+uhZFyXcSanZ0407ramhl+Sw3H3hLKisc7LCam5AX6w7U+n2DU5n0ab5RyMRIV4wHgZWqgrH6Q+JDbepKz6cIFdW6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=jZiPCxd3; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jZiPCxd3" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-35a1230c60eso331894a91.3 for ; Wed, 18 Mar 2026 20:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1773890676; x=1774495476; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fI9rzW2aMBEATJKy6J7V1Mrvg5oTiG1wsCzQGFVE56A=; b=jZiPCxd3K9h2WZ6QqHEo2Z/nni/HGNO8moB+dH4SZlZlqLQt3/fCDmW0kTx6Fu4oIX 91w0HpEWW3KebuvXgiOQWb5gL4LcGAIfiytxlMdfVJkgpmWGdvZH50Ay8pAyAykAnQAD /61UlhVNzFUpmFCThy8lxhfi14w+mqXRDeiZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773890676; x=1774495476; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fI9rzW2aMBEATJKy6J7V1Mrvg5oTiG1wsCzQGFVE56A=; b=IyW2EDXC17GpFgdWasvaesB/WZxOoDJjNVDm1Ol7+5NT1RaGBbNg8iR1uIfuKBtnvi tmpCZ4n8hFXio+WhSSGeweJ24Xr4lDNtI7bEJULP5Xv8TO4PMSl2bsk5oPNvPRXeJg3B iRlc1C2YC1uj8ynzFtLxuXlISEzqjwKbEUkx+1ELsBWgMUpdhYLI2c+eLY/zzjB8ootW bOiffPIgkp3sBQIrCCj1fPMRXBg4BMzhLGg4sekicFn9vQpWfM+BGiQ46aXrd14nx1rj miSSHN4l4AE8xi8DTUC+piVJMyxx5rIX7ILyHLNvhhsAnACTKohf6FCU2xlatbGD1mOF BcPQ== X-Forwarded-Encrypted: i=1; AJvYcCVXLo+nLwif+fMi3qYn2yjrIQR/JPzAu/dg7ors4JwglddGyWrjHa/qiFmas/Y0M9tb5yR9URAfvyUWYOo=@vger.kernel.org X-Gm-Message-State: AOJu0YxGL+fVTtPmUy8Trfp78LGaXN6AxC7gwpqmDz443rLnqCHk+0pR Hmtz44Q/a9qOwszlr8A/2pmcswe8A4/WxuTDat8oR5/qhH2Fp/Q6b2eFmUgItdSbAw== X-Gm-Gg: ATEYQzzKARSvv5K4PpB7P1fHYl2/cnq28csOpmN1CVqf5q+fzIQo/eBCSP4wDR/aU2m zfOhoYbzmdxhcCLZi0VngFbM4ryEQtdV1D3edGGRW3sXlBP+KbagSZ8ANHuSgY3cAK2d9KWnLZl uCkJ4jnfx2L9i8zYcl+1hNYSAjVjG0+49I77cWYRSbT8CJRRoFlRube4vZFZCWkf5zTOlXN2Zpe baNn1/7tyoQKpFvdy2o3cCFTy6GvGhgfqP+V5BMz/LdE3BteCYHOosVKrPhNWgy+32A/vjkhGti HGFxsEXGSSihMqIHEEy1A9DRD1oHqbWirGPxXkMguN3FUplU2XDhdTQyyrkNfKTCrS+yIdhtasb q4BBvmny9RfkKaYzFVH41R78JbZiZIY23w01+LTYGOSAQUvQVutCT/ilq3hwzZkMNiwGlMo48iC KFjXJ1GuuDGPjB8IHLd7EVOT+8C+zf3k3ZUu+1XyTsjU6iBS6AbNOe+PUKaLrhoFA= X-Received: by 2002:a17:90b:3512:b0:35b:9a22:deb1 with SMTP id 98e67ed59e1d1-35bb9e51036mr5058277a91.8.1773890675925; Wed, 18 Mar 2026 20:24:35 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:13e1:7517:52f3:cfc8]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35bc62f8e55sm1293261a91.9.2026.03.18.20.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 20:24:35 -0700 (PDT) Date: Thu, 19 Mar 2026 12:24:32 +0900 From: Sergey Senozhatsky To: Hui Zhu , Andrew Morton Cc: Minchan Kim , Sergey Senozhatsky , linux-mm@kvack.org, linux-kernel@vger.kernel.org, teawater Subject: Re: [PATCH v2] zsmalloc: return -EBUSY for zspage migration lock contention Message-ID: References: <20260319030709.62556-1-hui.zhu@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=us-ascii Content-Disposition: inline In-Reply-To: <20260319030709.62556-1-hui.zhu@linux.dev> On (26/03/19 11:07), Hui Zhu wrote: > movable_operations::migrate_page() should return an appropriate error > code for temporary migration failures so the migration core can handle > them correctly. > > zs_page_migrate() currently returns -EINVAL when zspage_write_trylock() > fails. That path reflects transient lock contention, not invalid input, > so -EINVAL is clearly wrong. > > However, -EAGAIN is also inappropriate here: the zspage's reader-lock > owner may hold the lock for an unbounded duration due to slow > decompression. Since migration retries are bounded by > NR_MAX_MIGRATE_PAGES_RETRY and performed with virtually no delay between > attempts, there is no guarantee the lock will be released in time for a > retry to succeed. -EAGAIN implies "try again soon", which does not hold > in this case. > > Return -EBUSY instead, which more accurately conveys that the resource > is occupied and migration cannot proceed at this time. > > Changelog: > v2: > According to the comments of Sergey Senozhatsky, change from -EAGAIN to > -EBUSY and add comments. I assume this Changelog was supposed to be under "---". > + /* > + * Return -EBUSY but not -EAGAIN: the zspage's reader-lock > + * owner may hold the lock for an unbounded duration due to a > + * slow decompression. ^^^ or reader-lock owner preemption > + * Since migration retries are bounded by > + * NR_MAX_MIGRATE_PAGES_RETRY and performed with virtually no > + * delay between attempts, there is no guarantee the lock will > + * be released in time for a retry to succeed. > + * -EAGAIN implies "try again soon", which does not hold here. > + * -EBUSY more accurately conveys "resource is occupied, > + * migration cannot proceed". > + */ > + return -EBUSY; > } Otherwise, Acked-by: Sergey Senozhatsky