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 CCA8236BCCA for ; Thu, 5 Mar 2026 12:46:36 +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=1772714796; cv=none; b=bjtRkkNP39nLpJTeIb1ZYox5uH+RyjGTCuhbuyO1hNurJNyhdtWrzYl23HKMbgDUnRHD50c0msNacWtlQDpm35YepfzuDdbBkux8Ey/n0V1SqBFk6dAOTKd3+rLH2mjDi0z+GT/9nHo34Yx7Z/Vuut7GfC+ntaagjxIX9IiDCPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772714796; c=relaxed/simple; bh=Qdwfpvgsgpr6yfgAg3OTdpdcikiTy4SkbiVRhMT24LA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jprwCSiPVOgYBpaIx5SnIzfzLLPu2kASfW2BQRXjtwb/zsniDbmKvQLwUONXazOou/9rZ+wbc5kDCXVpelABZzmu1OZRyivotXjsCezy9d+6APMQ7bi9G/voDuAZPj0rQWiVVarwplLl/wlDDW6DJpKjCXzqlqotrflmaOX25nA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kN0xWwK+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kN0xWwK+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FC8FC19423; Thu, 5 Mar 2026 12:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772714796; bh=Qdwfpvgsgpr6yfgAg3OTdpdcikiTy4SkbiVRhMT24LA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kN0xWwK+CXTs++d6bbglMvxLbDAwcfPrJQHp1YKBJbeBPJjM7DFNDWMpEsmC0pmVh SD5PwI0Jdv0dpedYAo5lRPXR+2JJ+WPV28cuRNAlW4wzu7+nmbpTEKCvPRAqH2qXBe mi0JbWbsWCu1ItDHcljgtKUPoc9nXsrWdbx2XAqUjMZSJEEQOp4/YAJ4322pa8pnxm Z8fZqclTkKV9z6STUU1HC0zIKyTaKtcZ2mO6pyhDLQf0u1ctse/YzA4/A8ehPaEORj hPIA7DihX5R+bATvQhaSOG8jMH352nFj+d9oq7qgbL/xKvuAb9rWAaRaPtIobxQ63Z X9ot2UYRfYxfA== Date: Thu, 5 Mar 2026 12:46:27 +0000 From: "Lorenzo Stoakes (Oracle)" To: "David Hildenbrand (Arm)" Cc: Kiryl Shutsemau , Breno Leitao , Andrew Morton , Lorenzo Stoakes , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, usamaarif642@gmail.com, kernel-team@meta.com Subject: Re: [PATCH 0/2] mm: thp: reduce unnecessary start_stop_khugepaged() calls Message-ID: <8042a515-e88a-4b4c-a5ab-d4eb6deaf4b3@lucifer.local> References: <20260304-thp_logs-v1-0-59038218a253@debian.org> 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: On Thu, Mar 05, 2026 at 12:45:56PM +0000, Lorenzo Stoakes (Oracle) wrote: > On Thu, Mar 05, 2026 at 01:41:33PM +0100, David Hildenbrand (Arm) wrote: > > > > >> + > > >> + /* Check if anything has to be done */ > > >> + if (hugepage_pmd_enabled() == !!khugepaged_thread) > > > > > > This is horrible, better to break out the latter expression as a small static > > > function like: > > > > > > static bool is_khugepaged_thread_running(void) > > > { > > > if (khugepaged_thread) > > > return true; > > > return false; > > > > return khugepaged_thread; > > > > should do the trick, given taht the return type of the function is a bool :) > > Yeah I know :) > > I mean it's subjective, but this form makes it clear that what you're returning > is _not_ a boolean. Sorry obviously meant to say what you're TESTING not what you're RETURNING. > > I was a bit 'meh' when I first saw this pattern, but it's grown on me, sort of a > 'make it so simple you can't get confused' kinda thing. > > > > > > } > > > > -- > > Cheers, > > > > David > > Cheers, Lorenzo