From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 89720183CB0 for ; Wed, 8 Jan 2025 02:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736303384; cv=none; b=s+Mw+bva6Sg4jyIAa0ONjbTSNoCPB8DY++dbfrmA/9Ei+qZ4IQn9NgLWXT3rlRnJiAC0dBB3le5zjW9YxSQ37pq4/493imzUFMxbSapixY2QBxDHBowUi+cHu3LOpMry5HCJg6NFqqJrBcdc5+ab6BDLC2NjK7+MEUg+93mt0fM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736303384; c=relaxed/simple; bh=mL9reFc0HLu2wuZ62Rlfp9/vEt9nVFkl8Lb3CNqNeEI=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=cORrqpOm78/gpFu8JH3lzPpRfJPYcStGsWOjltrq+3pwE4oUiNaJc4yn9QHBmtvBvi3diYlkwcdLtpAij+QzRWsvWzPPmvdjTQ2bek6rklKuzioRYld1DpRDqVFXAN9yqb13enMLS9tuUhgWnY2+/ZLPEPKs3uWgponJUloBI6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Vu7A6H9J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Vu7A6H9J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E695FC4CED6; Wed, 8 Jan 2025 02:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1736303384; bh=mL9reFc0HLu2wuZ62Rlfp9/vEt9nVFkl8Lb3CNqNeEI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Vu7A6H9JO2k7oCGoJjOZCcMZoEuVbcGb6KE8m92igY54Y3bv3K9ynNhZ+LMloEtik ZmMHZdXjK0Pylr4+hbJQUh3RkF87KSqSnFBYcbLoGXRLzvod6n/nJ6nXCCMBH3aw4f iKWFx4oTU+Kyw/LZ8NdUwEjZAkRACErHQz1NnPNc= Date: Tue, 7 Jan 2025 18:29:43 -0800 From: Andrew Morton To: Baolin Wang Cc: hughd@google.com, willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, kasong@tencent.com, ying.huang@linux.alibaba.com, 21cnbao@gmail.com, ryan.roberts@arm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] mm: shmem: skip swapcache for swapin of synchronous swap device Message-Id: <20250107182943.a36b6876985dac7d34ef07a2@linux-foundation.org> In-Reply-To: <3d9f3bd3bc6ec953054baff5134f66feeaae7c1e.1736301701.git.baolin.wang@linux.alibaba.com> References: <3d9f3bd3bc6ec953054baff5134f66feeaae7c1e.1736301701.git.baolin.wang@linux.alibaba.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Wed, 8 Jan 2025 10:16:49 +0800 Baolin Wang wrote: > +static struct folio *shmem_swap_alloc_folio(struct inode *inode, > + struct vm_area_struct *vma, pgoff_t index, > + swp_entry_t entry, int order, gfp_t gfp) > +{ > + struct shmem_inode_info *info = SHMEM_I(inode); > + struct folio *new; > + void *shadow; > + int nr_pages; > + > + /* > + * We have arrived here because our zones are constrained, so don't > + * limit chance of success by further cpuset and node constraints. > + */ > + gfp &= ~GFP_CONSTRAINT_MASK; > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + if (order > 0) { > + gfp_t huge_gfp = vma_thp_gfp_mask(vma); > + > + gfp = limit_gfp_mask(huge_gfp, gfp); > + } > +#endif > + Can we do this? --- a/mm/shmem.c~mm-shmem-skip-swapcache-for-swapin-of-synchronous-swap-device-fix +++ a/mm/shmem.c @@ -1978,16 +1978,14 @@ static struct folio *shmem_swap_alloc_fo /* * We have arrived here because our zones are constrained, so don't - * limit chance of success by further cpuset and node constraints. + * limit chance of success with further cpuset and node constraints. */ gfp &= ~GFP_CONSTRAINT_MASK; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (order > 0) { + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && order > 0) { gfp_t huge_gfp = vma_thp_gfp_mask(vma); gfp = limit_gfp_mask(huge_gfp, gfp); } -#endif new = shmem_alloc_folio(gfp, order, info, index); if (!new) _