From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C25DF2DCC08 for ; Tue, 9 Jun 2026 14:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781014394; cv=none; b=AO3CECOr7cvMCR3njQE146ZjeHH8DthGkpHaA98yGCg6lRIULl17D63k/mcjxnVmJIFbinCpgQQwGkh7JLYQth26x0m3fncMZWN8bitUDsq2DKEMRjGmoPpompDbxb/EG/OpfBz3wCoDrUQNAMW/hcySs2igSybp6uDsBUMRJ/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781014394; c=relaxed/simple; bh=3oP6QoR8rF3/6Xag/AK21bpDd7WjM02Kdo/6qRfloD0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j5aDjElQ7pC4Q9L1Gr0XEUuPJgOCqoQ7XK5ZFUCDrbnZDsZPrZ+TdH2W8wGojXrxrAcevc8SmAjt5yLac+McnuK9r4DwiwnOja+9zU3NtgB0QMxAI+jPZ+pBKVXLenplY+Fn2hTgV3HtibJmqDgi0oXFVIhZbXAxS2dtpmSKSk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HG6mmjqR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HG6mmjqR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B0F41F00893; Tue, 9 Jun 2026 14:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781014393; bh=63y6tZ25VbAMNcuEdojeAVEa+zeL2wocNZmc2fUBwgM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HG6mmjqR1ABZQRp6AjNYevSAgPM09oPs9ZykgDI+gUCKpMuj/9tQEGKcErg8NtQ/T cxlAxyZnh92JxfBy91mfsqua9HetrSV8vnUiXdIXAVOgDNyc9Rt4HCzntYBVZW9nFR kdzCx2mRZ7DtahQFkbYigFA6sRLtMBOp5gm781NtfPeETU6X+Mrx4hdvr93BE3XfVa it3+/INVaH4w8ahSu5mvMKJOc9IluuE0xYAoaNSJYTBpU1avfrlIRN/n85WiUkfXhx Oh+LhOE43z3ae3LaC5SWc7DhXeNES2DNbAsNjw4iMaFr0uCj6oXa1Kc372lDZq3tr6 tA+zj49UPlXeA== Date: Tue, 9 Jun 2026 15:13:05 +0100 From: Lorenzo Stoakes To: Nico Pache Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Usama Arif , Yu Zhao , aarcange@redhat.com, Andrew Morton , David Hildenbrand , Xu Xin , Chengming Zhou , Zi Yan , Baolin Wang , "Liam R. Howlett" , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple Subject: Re: [PATCH mm-unstable v1 1/3] mm/ksm: export ksm_is_running() to check KSM merge state Message-ID: References: <20260609114619.144416-1-npache@redhat.com> <20260609114619.144416-2-npache@redhat.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: <20260609114619.144416-2-npache@redhat.com> On Tue, Jun 09, 2026 at 05:46:13AM -0600, Nico Pache wrote: > Add ksm_is_running() which returns true when KSM is actively merging > (ksm_run & KSM_RUN_MERGE). > > This will be used by try_to_map_unused_to_zeropage() to skip zero-page > remapping in VM_MERGEABLE VMAs when KSM is active. > > Signed-off-by: Nico Pache > --- > include/linux/ksm.h | 6 ++++++ > mm/ksm.c | 6 ++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/linux/ksm.h b/include/linux/ksm.h > index d39d0d5483a2..c1048b690a92 100644 > --- a/include/linux/ksm.h > +++ b/include/linux/ksm.h > @@ -17,6 +17,7 @@ > #ifdef CONFIG_KSM > int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > unsigned long end, int advice, vm_flags_t *vm_flags); > +bool ksm_is_running(void); > vma_flags_t ksm_vma_flags(struct mm_struct *mm, const struct file *file, > vma_flags_t vma_flags); > int ksm_enable_merge_any(struct mm_struct *mm); > @@ -144,6 +145,11 @@ static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > return 0; > } > > +static inline bool ksm_is_running(void) > +{ > + return false; > +} > + > static inline struct folio *ksm_might_need_to_copy(struct folio *folio, > struct vm_area_struct *vma, unsigned long addr) > { > diff --git a/mm/ksm.c b/mm/ksm.c > index 7d5b76478f0b..edc2b961ff59 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -3015,6 +3015,12 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > } > EXPORT_SYMBOL_GPL(ksm_madvise); > > +bool ksm_is_running(void) > +{ > + return ksm_run & KSM_RUN_MERGE; > +} > +EXPORT_SYMBOL_GPL(ksm_is_running); Why are we exporting this? What modules need this? We should never export unless we have a very specific reason to. > + > int __ksm_enter(struct mm_struct *mm) > { > struct ksm_mm_slot *mm_slot; > -- > 2.54.0 >