From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kristen Carlson Accardi Subject: [RFC PATCH 01/20] x86/sgx: Call cond_resched() at the end of sgx_reclaim_pages() Date: Thu, 22 Sep 2022 10:10:38 -0700 Message-ID: <20220922171057.1236139-2-kristen@linux.intel.com> References: <20220922171057.1236139-1-kristen@linux.intel.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663866673; x=1695402673; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ifb30cg6P3JKvBBa008GWBRWYGH5CsWJa5YGYBaxzPg=; b=iGeegM4aoNIwR7xjkvi4BBeFVBXbC+s0Po3o98gR1hhnt6qMWYM4zFPc SFsX1tM0B3XwRhPffvTOMCMEdIseGOaVjwG5RCY9EQpYewVLARxbPHs0e epcj0OviE++mhinBnE5aDIXD01w7TOOrzyXmxmKIA3Ui/GH30DaUj3auj KT0u+UAvuXCkfCDQYEXOiNbjFwjB5+Wc6/7nFO+sXPZjeBsAzQaXf6Y0h pYqTH73ETk1pu79nCWHcwAVJGJEp4bJKaDTjPUC600u2IdmxajYs7R3z3 kEsKzvGiprIIqmX33riSiVrAY8fl9NQNBGux0mAI5/obywq3JJicunDly w==; In-Reply-To: <20220922171057.1236139-1-kristen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-sgx-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, "H. Peter Anvin" Cc: Kristen Carlson Accardi , Sean Christopherson From: Sean Christopherson Move the invocation of post-reclaim cond_resched() from the callers of sgx_reclaim_pages() into the reclaim path itself. sgx_reclaim_pages() is always called in a loop and is always followed by a call to cond_resched(). This will hold true for the EPC cgroup as well, which adds even more calls to sgx_reclaim_pages() and thus cond_resched(). Signed-off-by: Sean Christopherson Signed-off-by: Kristen Carlson Accardi Cc: Sean Christopherson --- arch/x86/kernel/cpu/sgx/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index 515e2a5f25bb..4cdeb915dc86 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -367,6 +367,8 @@ static void sgx_reclaim_pages(void) sgx_free_epc_page(epc_page); } + + cond_resched(); } static bool sgx_should_reclaim(unsigned long watermark) @@ -410,8 +412,6 @@ static int ksgxd(void *p) if (sgx_should_reclaim(SGX_NR_HIGH_PAGES)) sgx_reclaim_pages(); - - cond_resched(); } return 0; @@ -578,7 +578,6 @@ struct sgx_epc_page *sgx_alloc_epc_page(void *owner, bool reclaim) } sgx_reclaim_pages(); - cond_resched(); } if (sgx_should_reclaim(SGX_NR_LOW_PAGES)) -- 2.37.3