From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 923E47E765 for ; Wed, 8 Jan 2025 02:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736304071; cv=none; b=KjH22y8IOzICXHn4XtyQjRmkDcD5gGbndp2RgIy7c+15ntvV2TqEMwQ4g1xAx30oAGmbRGhcChbdj+/1vmwu4IPbi3bjd0pptK4pZ5MPd+wIdMEzBSrlfTEvxtviTLYojEJL7x35LC212G+0+/9jD2Mkzh8h4m48q25798nlShM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736304071; c=relaxed/simple; bh=P1VGGJMnScXiGqVsDxvBfVFXGMtxAq/Hpy1Wn9sRxqU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=o7hPnAN/TPVmWC4kTSyxZfThR/qnTJeWbryvb1FwgF3Db/6FP4qrUozEPedeM1aA7i0xLOZ3kTeTb6W/zNP7xtUj8lKdRf151nGsatcnaSlvQqtFWcMhEESpGisGtET91IDIXzeZM06J9kzjdv9+tD9Jo13MzY2XD7OP+kECaj0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=odVpL4hR; arc=none smtp.client-ip=115.124.30.118 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="odVpL4hR" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1736304065; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=LtmJxFHr8zPtAUr4goIsq9kiiAdDmXqBnP+rU6IOmBE=; b=odVpL4hRJLj7v/4vn47JGCypeEFisI8XGYVFQlF237UYMUy4s0g2YeOUwg3asxWOkLNOrwEHSNar0pSSOOyB0CqNp53wGNyh6NJ664tDaOStxAPKaVFvJwhr3I90/COI5PQQ37mY22YWOZ12ZVrcy2KR69KV2g/0HPKQllzN9cw= Received: from 30.74.144.127(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WNCFcNG_1736304063 cluster:ay36) by smtp.aliyun-inc.com; Wed, 08 Jan 2025 10:41:04 +0800 Message-ID: <3dfe49b0-e852-4989-ac03-22418cc2e1a1@linux.alibaba.com> Date: Wed, 8 Jan 2025 10:41:02 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm: shmem: skip swapcache for swapin of synchronous swap device To: Andrew Morton 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 References: <3d9f3bd3bc6ec953054baff5134f66feeaae7c1e.1736301701.git.baolin.wang@linux.alibaba.com> <20250107182943.a36b6876985dac7d34ef07a2@linux-foundation.org> From: Baolin Wang In-Reply-To: <20250107182943.a36b6876985dac7d34ef07a2@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025/1/8 10:29, Andrew Morton wrote: > 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) > _ Yes, looks good to me. Thanks.