Re: [PATCH v5 07/18] x86/sgx: Introduce RECLAIM_IN_PROGRESS state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> @@ -312,13 +312,15 @@ static void sgx_reclaim_pages(void)
>  		list_del_init(&epc_page->list);
>  		encl_page = epc_page->owner;
>  
> -		if (kref_get_unless_zero(&encl_page->encl->refcount) != 0)
> +		if (kref_get_unless_zero(&encl_page->encl->refcount) != 0) {
> +			sgx_epc_page_set_state(epc_page, SGX_EPC_PAGE_RECLAIM_IN_PROGRESS);
>  			chunk[cnt++] = epc_page;
> -		else
> +		} else {
>  			/* The owner is freeing the page. No need to add the
>  			 * page back to the list of reclaimable pages.
>  			 */

Please use proper comment style:

For single line comment:

	/* ... */

For multiple lines comment:

	/*
	 * ...
	 */
	
>  			sgx_epc_page_reset_state(epc_page);
> +		}

Nit: unintended new {} around 'else'?

>  	}
>  	spin_unlock(&sgx_global_lru.lock);
>  
> @@ -528,16 +530,13 @@ void sgx_record_epc_page(struct sgx_epc_page *page, unsigned long flags)
>  int sgx_drop_epc_page(struct sgx_epc_page *page)
>  {
>  	spin_lock(&sgx_global_lru.lock);
> -	if (sgx_epc_page_reclaimable(page->flags)) {
> -		/* The page is being reclaimed. */
> -		if (list_empty(&page->list)) {
> -			spin_unlock(&sgx_global_lru.lock);
> -			return -EBUSY;
> -		}
> -
> -		list_del(&page->list);
> -		sgx_epc_page_reset_state(page);
> +	if (sgx_epc_page_reclaim_in_progress(page->flags)) {
> +		spin_unlock(&sgx_global_lru.lock);
> +		return -EBUSY;
>  	}
> +
> +	list_del(&page->list);
> +	sgx_epc_page_reset_state(page);
>  	spin_unlock(&sgx_global_lru.lock);
>  
>  	return 0;
> diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h
> index 2faeb40b345f..764cec23f4e5 100644
> --- a/arch/x86/kernel/cpu/sgx/sgx.h
> +++ b/arch/x86/kernel/cpu/sgx/sgx.h
> @@ -40,6 +40,8 @@ enum sgx_epc_page_state {
>  
>  	/* Page is in use and tracked in a reclaimable LRU list
>  	 * Becomes NOT_TRACKED after sgx_drop_epc()
> +	 * Becomes RECLAIM_IN_PROGRESS in sgx_reclaim_pages() when identified
> +	 * for reclaiming
>  	 */
>  	SGX_EPC_PAGE_RECLAIMABLE = 2,
>  
> @@ -50,6 +52,14 @@ enum sgx_epc_page_state {
>  	 */
>  	SGX_EPC_PAGE_UNRECLAIMABLE = 3,
>  
> +	/* Page is being prepared for reclamation, tracked in a temporary
> +	 * isolated list by the reclaimer.
> +	 * Changes in sgx_reclaim_pages() back to RECLAIMABLE if preparation
> +	 * fails for any reason.
> +	 * Becomes NOT_TRACKED if reclaimed successfully in sgx_reclaim_pages()
> +	 * and immediately sgx_free_epc() is called to make it FREE.
> +	 */

Ditto for  the comment style.

And please use blank line to separate paragraphs for better readability.




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux