diff mbox

powerpc/pseries: Move CMO code from plapr_wrappers.h to platforms/pseries

Message ID 1479106005-18460-1-git-send-email-mpe@ellerman.id.au (mailing list archive)
State Accepted
Headers show

Commit Message

Michael Ellerman Nov. 14, 2016, 6:46 a.m. UTC
Currently there's some CMO (Cooperative Memory Overcommit) code, in
plpar_wrappers.h. Some of it is #ifdef CONFIG_PSERIES and some of it
isn't. The end result being if a file includes plpar_wrappers.h it won't
build with CONFIG_PSERIES=n.

Fix it by moving the CMO code into platforms/pseries. The two hcall
wrappers can just be moved into their only caller, cmm.c, and the
accessors can go in pseries.h.

Note we need the accessors because cmm.c can be built as a module, so
there needs to be a split between the built-in code vs the module, and
that's achieved by using those accessors.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/hvcall.h         | 21 --------------------
 arch/powerpc/include/asm/plpar_wrappers.h | 32 -------------------------------
 arch/powerpc/platforms/pseries/cmm.c      | 32 +++++++++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/pseries.h  | 19 ++++++++++++++++++
 4 files changed, 51 insertions(+), 53 deletions(-)

Comments

kernel test robot Nov. 14, 2016, 7:22 a.m. UTC | #1
Hi Michael,

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.9-rc5 next-20161111]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Michael-Ellerman/powerpc-pseries-Move-CMO-code-from-plapr_wrappers-h-to-platforms-pseries/20161114-145812
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allmodconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/platforms/pseries/cmm.c: In function 'plpar_page_set_loaned':
>> arch/powerpc/platforms/pseries/cmm.c:114:30: error: implicit declaration of function 'cmo_get_page_size' [-Werror=implicit-function-declaration]
     unsigned long cmo_page_sz = cmo_get_page_size();
                                 ^~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/cmo_get_page_size +114 arch/powerpc/platforms/pseries/cmm.c

   108	static int hotplug_occurred; /* protected by the hotplug mutex */
   109	
   110	static struct task_struct *cmm_thread_ptr;
   111	
   112	static long plpar_page_set_loaned(unsigned long vpa)
   113	{
 > 114		unsigned long cmo_page_sz = cmo_get_page_size();
   115		long rc = 0;
   116		int i;
   117	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Nov. 14, 2016, 8:15 a.m. UTC | #2
Hi Michael,

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.9-rc5 next-20161114]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Michael-Ellerman/powerpc-pseries-Move-CMO-code-from-plapr_wrappers-h-to-platforms-pseries/20161114-145812
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/platforms/pseries/lparcfg.c: In function 'pseries_cmo_data':
   arch/powerpc/platforms/pseries/lparcfg.c:403:40: error: implicit declaration of function 'cmo_get_primary_psp' [-Werror=implicit-function-declaration]
     seq_printf(m, "cmo_primary_psp=%d\n", cmo_get_primary_psp());
                                           ^~~~~~~~~~~~~~~~~~~
   arch/powerpc/platforms/pseries/lparcfg.c:404:42: error: implicit declaration of function 'cmo_get_secondary_psp' [-Werror=implicit-function-declaration]
     seq_printf(m, "cmo_secondary_psp=%d\n", cmo_get_secondary_psp());
                                             ^~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/platforms/pseries/lparcfg.c:405:39: error: implicit declaration of function 'cmo_get_page_size' [-Werror=implicit-function-declaration]
     seq_printf(m, "cmo_page_size=%lu\n", cmo_get_page_size());
                                          ^~~~~~~~~~~~~~~~~
>> arch/powerpc/platforms/pseries/lparcfg.c:405:33: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Werror=format=]
     seq_printf(m, "cmo_page_size=%lu\n", cmo_get_page_size());
                                    ^
   cc1: all warnings being treated as errors

vim +405 arch/powerpc/platforms/pseries/lparcfg.c

7ffcf8ec arch/powerpc/kernel/lparcfg.c Anton Blanchard 2013-08-07  397  		cmo_fault_time += be64_to_cpu(lppaca_of(cpu).cmo_fault_time);
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  398  	}
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  399  
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  400  	seq_printf(m, "cmo_faults=%lu\n", cmo_faults);
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  401  	seq_printf(m, "cmo_fault_time_usec=%lu\n",
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  402  		   cmo_fault_time / tb_ticks_per_usec);
ac22429d arch/powerpc/kernel/lparcfg.c Robert Jennings 2008-08-16 @403  	seq_printf(m, "cmo_primary_psp=%d\n", cmo_get_primary_psp());
ac22429d arch/powerpc/kernel/lparcfg.c Robert Jennings 2008-08-16  404  	seq_printf(m, "cmo_secondary_psp=%d\n", cmo_get_secondary_psp());
ac22429d arch/powerpc/kernel/lparcfg.c Robert Jennings 2008-08-16 @405  	seq_printf(m, "cmo_page_size=%lu\n", cmo_get_page_size());
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  406  }
ffa5abbd arch/powerpc/kernel/lparcfg.c Brian King      2008-07-24  407  
0559f0a7 arch/powerpc/kernel/lparcfg.c Anton Blanchard 2009-03-31  408  static void splpar_dispatch_data(struct seq_file *m)

:::::: The code at line 405 was first introduced by commit
:::::: ac22429df22c1c793245c3cca33ccde4046d9c1f powerpc: Add CMO enabled flag and paging space data to lparcfg

:::::: TO: Robert Jennings <rcj@linux.vnet.ibm.com>
:::::: CC: Paul Mackerras <paulus@samba.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Michael Ellerman Nov. 17, 2016, 12:04 p.m. UTC | #3
On Mon, 2016-14-11 at 06:46:45 UTC, Michael Ellerman wrote:
> Currently there's some CMO (Cooperative Memory Overcommit) code, in
> plpar_wrappers.h. Some of it is #ifdef CONFIG_PSERIES and some of it
> isn't. The end result being if a file includes plpar_wrappers.h it won't
> build with CONFIG_PSERIES=n.
> 
> Fix it by moving the CMO code into platforms/pseries. The two hcall
> wrappers can just be moved into their only caller, cmm.c, and the
> accessors can go in pseries.h.
> 
> Note we need the accessors because cmm.c can be built as a module, so
> there needs to be a split between the built-in code vs the module, and
> that's achieved by using those accessors.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/8f272a5dd6826f14e47110eccd37b6

cheers
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
index 708edebcf147..1acdcad5f773 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -412,27 +412,6 @@  static inline unsigned int get_longbusy_msecs(int longbusy_rc)
 	}
 }
 
-#ifdef CONFIG_PPC_PSERIES
-extern int CMO_PrPSP;
-extern int CMO_SecPSP;
-extern unsigned long CMO_PageSize;
-
-static inline int cmo_get_primary_psp(void)
-{
-	return CMO_PrPSP;
-}
-
-static inline int cmo_get_secondary_psp(void)
-{
-	return CMO_SecPSP;
-}
-
-static inline unsigned long cmo_get_page_size(void)
-{
-	return CMO_PageSize;
-}
-#endif /* CONFIG_PPC_PSERIES */
-
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_HVCALL_H */
diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index 1b394247afc2..034a588b122c 100644
--- a/arch/powerpc/include/asm/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -93,38 +93,6 @@  static inline long register_dtl(unsigned long cpu, unsigned long vpa)
 	return vpa_call(H_VPA_REG_DTL, cpu, vpa);
 }
 
-static inline long plpar_page_set_loaned(unsigned long vpa)
-{
-	unsigned long cmo_page_sz = cmo_get_page_size();
-	long rc = 0;
-	int i;
-
-	for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
-		rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
-
-	for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
-		plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
-				   vpa + i - cmo_page_sz, 0);
-
-	return rc;
-}
-
-static inline long plpar_page_set_active(unsigned long vpa)
-{
-	unsigned long cmo_page_sz = cmo_get_page_size();
-	long rc = 0;
-	int i;
-
-	for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
-		rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
-
-	for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
-		plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
-				   vpa + i - cmo_page_sz, 0);
-
-	return rc;
-}
-
 extern void vpa_init(int cpu);
 
 static inline long plpar_pte_enter(unsigned long flags,
diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index 66e7227469b8..4412f12374d3 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -109,6 +109,38 @@  static int hotplug_occurred; /* protected by the hotplug mutex */
 
 static struct task_struct *cmm_thread_ptr;
 
+static long plpar_page_set_loaned(unsigned long vpa)
+{
+	unsigned long cmo_page_sz = cmo_get_page_size();
+	long rc = 0;
+	int i;
+
+	for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
+		rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
+
+	for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
+		plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
+				   vpa + i - cmo_page_sz, 0);
+
+	return rc;
+}
+
+static long plpar_page_set_active(unsigned long vpa)
+{
+	unsigned long cmo_page_sz = cmo_get_page_size();
+	long rc = 0;
+	int i;
+
+	for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
+		rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
+
+	for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
+		plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
+				   vpa + i - cmo_page_sz, 0);
+
+	return rc;
+}
+
 /**
  * cmm_alloc_pages - Allocate pages and mark them as loaned
  * @nr:	number of pages to allocate
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index b1be7b713fe6..1361a9db534b 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -79,4 +79,23 @@  extern struct pci_controller_ops pseries_pci_controller_ops;
 
 unsigned long pseries_memory_block_size(void);
 
+extern int CMO_PrPSP;
+extern int CMO_SecPSP;
+extern unsigned long CMO_PageSize;
+
+static inline int cmo_get_primary_psp(void)
+{
+	return CMO_PrPSP;
+}
+
+static inline int cmo_get_secondary_psp(void)
+{
+	return CMO_SecPSP;
+}
+
+static inline unsigned long cmo_get_page_size(void)
+{
+	return CMO_PageSize;
+}
+
 #endif /* _PSERIES_PSERIES_H */