diff mbox series

[for_v31,2/6] x86/sgx: Remove unnecessary globals after merging reclaim.c into main.c

Message ID 20200529175407.2109-3-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/sgx: Misc fixes for v31 | expand

Commit Message

Sean Christopherson May 29, 2020, 5:54 p.m. UTC
Make all variables that are only used in main.c static, rearranging code
as needed.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kernel/cpu/sgx/main.c | 16 ++++++----------
 arch/x86/kernel/cpu/sgx/sgx.h  |  3 ---
 2 files changed, 6 insertions(+), 13 deletions(-)

Comments

Jarkko Sakkinen May 30, 2020, 8:43 a.m. UTC | #1
On Fri, May 29, 2020 at 10:54:03AM -0700, Sean Christopherson wrote:
> Make all variables that are only used in main.c static, rearranging code
> as needed.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

As with merging, it is a multiphase process to make these changes.

I.e. I'll do manually similar changes but cannot use this patch for
anything.

/Jarkko

> ---
>  arch/x86/kernel/cpu/sgx/main.c | 16 ++++++----------
>  arch/x86/kernel/cpu/sgx/sgx.h  |  3 ---
>  2 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
> index 5043d3700960b..ef7061bfa2a07 100644
> --- a/arch/x86/kernel/cpu/sgx/main.c
> +++ b/arch/x86/kernel/cpu/sgx/main.c
> @@ -14,9 +14,12 @@
>  #include "encls.h"
>  
>  static struct task_struct *ksgxswapd_tsk;
> -DECLARE_WAIT_QUEUE_HEAD(ksgxswapd_waitq);
> -LIST_HEAD(sgx_active_page_list);
> -DEFINE_SPINLOCK(sgx_active_page_list_lock);
> +static DECLARE_WAIT_QUEUE_HEAD(ksgxswapd_waitq);
> +static LIST_HEAD(sgx_active_page_list);
> +static DEFINE_SPINLOCK(sgx_active_page_list_lock);
> +
> +struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
> +static int sgx_nr_epc_sections;
>  
>  static void sgx_sanitize_section(struct sgx_epc_section *section)
>  {
> @@ -45,10 +48,6 @@ static void sgx_sanitize_section(struct sgx_epc_section *section)
>  	}
>  }
>  
> -extern struct task_struct *ksgxswapd_tsk;
> -extern struct wait_queue_head(ksgxswapd_waitq);
> -extern spinlock_t sgx_active_page_list_lock;
> -
>  static unsigned long sgx_nr_free_pages(void)
>  {
>  	unsigned long cnt = 0;
> @@ -491,9 +490,6 @@ void sgx_reclaim_pages(void)
>  	}
>  }
>  
> -struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
> -int sgx_nr_epc_sections;
> -
>  static struct sgx_epc_page *__sgx_alloc_epc_page_from_section(struct sgx_epc_section *section)
>  {
>  	struct sgx_epc_page *page;
> diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h
> index 923028d568540..5b9dbcef981b0 100644
> --- a/arch/x86/kernel/cpu/sgx/sgx.h
> +++ b/arch/x86/kernel/cpu/sgx/sgx.h
> @@ -41,14 +41,11 @@ struct sgx_epc_section {
>  #define SGX_NR_LOW_PAGES		32
>  #define SGX_NR_HIGH_PAGES		64
>  
> -extern struct list_head sgx_active_page_list;
> -
>  void sgx_mark_page_reclaimable(struct sgx_epc_page *page);
>  int sgx_unmark_page_reclaimable(struct sgx_epc_page *page);
>  void sgx_reclaim_pages(void);
>  
>  extern struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
> -extern int sgx_nr_epc_sections;
>  
>  static inline struct sgx_epc_section *sgx_get_epc_section(
>  		struct sgx_epc_page *page)
> -- 
> 2.26.0
>
Jarkko Sakkinen May 30, 2020, 8:47 a.m. UTC | #2
On Sat, May 30, 2020 at 11:43:39AM +0300, Jarkko Sakkinen wrote:
> On Fri, May 29, 2020 at 10:54:03AM -0700, Sean Christopherson wrote:
> > Make all variables that are only used in main.c static, rearranging code
> > as needed.
> > 
> > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> 
> As with merging, it is a multiphase process to make these changes.
> 
> I.e. I'll do manually similar changes but cannot use this patch for
> anything.

Also this moves sgx_nr_epc_sections and sgx_epc_sections to a wrong
location. Reclaimer code is before other code. I don't understand
why sgx_epc_sections had to be moved as part of changing variables
to static.

/Jarkko
Jarkko Sakkinen May 30, 2020, 10:36 a.m. UTC | #3
On Sat, May 30, 2020 at 11:47:39AM +0300, Jarkko Sakkinen wrote:
> On Sat, May 30, 2020 at 11:43:39AM +0300, Jarkko Sakkinen wrote:
> > On Fri, May 29, 2020 at 10:54:03AM -0700, Sean Christopherson wrote:
> > > Make all variables that are only used in main.c static, rearranging code
> > > as needed.
> > > 
> > > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> > 
> > As with merging, it is a multiphase process to make these changes.
> > 
> > I.e. I'll do manually similar changes but cannot use this patch for
> > anything.
> 
> Also this moves sgx_nr_epc_sections and sgx_epc_sections to a wrong
> location. Reclaimer code is before other code. I don't understand
> why sgx_epc_sections had to be moved as part of changing variables
> to static.

I think should be right now :-)

/Jarkko
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index 5043d3700960b..ef7061bfa2a07 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -14,9 +14,12 @@ 
 #include "encls.h"
 
 static struct task_struct *ksgxswapd_tsk;
-DECLARE_WAIT_QUEUE_HEAD(ksgxswapd_waitq);
-LIST_HEAD(sgx_active_page_list);
-DEFINE_SPINLOCK(sgx_active_page_list_lock);
+static DECLARE_WAIT_QUEUE_HEAD(ksgxswapd_waitq);
+static LIST_HEAD(sgx_active_page_list);
+static DEFINE_SPINLOCK(sgx_active_page_list_lock);
+
+struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
+static int sgx_nr_epc_sections;
 
 static void sgx_sanitize_section(struct sgx_epc_section *section)
 {
@@ -45,10 +48,6 @@  static void sgx_sanitize_section(struct sgx_epc_section *section)
 	}
 }
 
-extern struct task_struct *ksgxswapd_tsk;
-extern struct wait_queue_head(ksgxswapd_waitq);
-extern spinlock_t sgx_active_page_list_lock;
-
 static unsigned long sgx_nr_free_pages(void)
 {
 	unsigned long cnt = 0;
@@ -491,9 +490,6 @@  void sgx_reclaim_pages(void)
 	}
 }
 
-struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
-int sgx_nr_epc_sections;
-
 static struct sgx_epc_page *__sgx_alloc_epc_page_from_section(struct sgx_epc_section *section)
 {
 	struct sgx_epc_page *page;
diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h
index 923028d568540..5b9dbcef981b0 100644
--- a/arch/x86/kernel/cpu/sgx/sgx.h
+++ b/arch/x86/kernel/cpu/sgx/sgx.h
@@ -41,14 +41,11 @@  struct sgx_epc_section {
 #define SGX_NR_LOW_PAGES		32
 #define SGX_NR_HIGH_PAGES		64
 
-extern struct list_head sgx_active_page_list;
-
 void sgx_mark_page_reclaimable(struct sgx_epc_page *page);
 int sgx_unmark_page_reclaimable(struct sgx_epc_page *page);
 void sgx_reclaim_pages(void);
 
 extern struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS];
-extern int sgx_nr_epc_sections;
 
 static inline struct sgx_epc_section *sgx_get_epc_section(
 		struct sgx_epc_page *page)