diff mbox series

[v12,09/11] mm: Allow arch code to override copy_highpage()

Message ID ecbafa2bfcc05f22183be2e7784ed11943b1d5b2.1519227112.git.khalid.aziz@oracle.com
State Accepted
Delegated to: David Miller
Headers show
Series Application Data Integrity feature introduced by SPARC M7 | expand

Commit Message

Khalid Aziz Feb. 21, 2018, 5:15 p.m. UTC
Some architectures can support metadata for memory pages and when a
page is copied, its metadata must also be copied. Sparc processors
from M7 onwards support metadata for memory pages. This metadata
provides tag based protection for access to memory pages. To maintain
this protection, the tag data must be copied to the new page when a
page is migrated across NUMA nodes. This patch allows arch specific
code to override default copy_highpage() and copy metadata along
with page data upon migration.

Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Cc: Khalid Aziz <khalid@gonehiking.org>
Reviewed-by: Anthony Yznaga <anthony.yznaga@oracle.com>
---
v9:
	- new patch

 include/linux/highmem.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Dave Hansen March 5, 2018, 7:24 p.m. UTC | #1
On 02/21/2018 09:15 AM, Khalid Aziz wrote:
> +#ifndef __HAVE_ARCH_COPY_HIGHPAGE
> +
>  static inline void copy_highpage(struct page *to, struct page *from)
>  {
>  	char *vfrom, *vto;
> @@ -248,4 +250,6 @@ static inline void copy_highpage(struct page *to, struct page *from)
>  	kunmap_atomic(vfrom);
>  }
>  
> +#endif

I think we prefer that these are CONFIG_* options.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Khalid Aziz March 5, 2018, 8:42 p.m. UTC | #2
On 03/05/2018 12:24 PM, Dave Hansen wrote:
> On 02/21/2018 09:15 AM, Khalid Aziz wrote:
>> +#ifndef __HAVE_ARCH_COPY_HIGHPAGE
>> +
>>   static inline void copy_highpage(struct page *to, struct page *from)
>>   {
>>   	char *vfrom, *vto;
>> @@ -248,4 +250,6 @@ static inline void copy_highpage(struct page *to, struct page *from)
>>   	kunmap_atomic(vfrom);
>>   }
>>   
>> +#endif
> 
> I think we prefer that these are CONFIG_* options.

I added this mechanism to be same as what we have for copy_user_highpage():

---------------
#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE

static inline void copy_user_highpage(struct page *to, struct page *from,
         unsigned long vaddr, struct vm_area_struct *vma)
{
----------------

There isn't a CONFIG_* option for copy_user_highpage() so I don't see a 
reason to add one for copy_highpage().

Do you see it differently? In that case, should there be a CONFIG_* 
option for copy_user_highpage() as well?

Thanks,
Khalid
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Hansen March 5, 2018, 8:56 p.m. UTC | #3
On 03/05/2018 12:42 PM, Khalid Aziz wrote:
> On 03/05/2018 12:24 PM, Dave Hansen wrote:
>> On 02/21/2018 09:15 AM, Khalid Aziz wrote:
>>> +#ifndef __HAVE_ARCH_COPY_HIGHPAGE
>>> +
>>>   static inline void copy_highpage(struct page *to, struct page *from)
>>>   {
>>>       char *vfrom, *vto;
>>> @@ -248,4 +250,6 @@ static inline void copy_highpage(struct page *to,
>>> struct page *from)
>>>       kunmap_atomic(vfrom);
>>>   }
>>>   +#endif
>>
>> I think we prefer that these are CONFIG_* options.
> 
> I added this mechanism to be same as what we have for copy_user_highpage():
> 
> ---------------
> #ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE

I think that's the old way that we generally don't want to add new
instances of.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Morton March 6, 2018, 10:48 p.m. UTC | #4
On Wed, 21 Feb 2018 10:15:51 -0700 Khalid Aziz <khalid.aziz@oracle.com> wrote:

> Some architectures can support metadata for memory pages and when a
> page is copied, its metadata must also be copied. Sparc processors
> from M7 onwards support metadata for memory pages. This metadata
> provides tag based protection for access to memory pages. To maintain
> this protection, the tag data must be copied to the new page when a
> page is migrated across NUMA nodes. This patch allows arch specific
> code to override default copy_highpage() and copy metadata along
> with page data upon migration.
> 
> ...
>
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -237,6 +237,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
>  
>  #endif
>  
> +#ifndef __HAVE_ARCH_COPY_HIGHPAGE
> +
>  static inline void copy_highpage(struct page *to, struct page *from)
>  {
>  	char *vfrom, *vto;
> @@ -248,4 +250,6 @@ static inline void copy_highpage(struct page *to, struct page *from)
>  	kunmap_atomic(vfrom);
>  }
>  
> +#endif
> +
>  #endif /* _LINUX_HIGHMEM_H */

It would be more consistent and conventional here to do

#ifndef copy_highpage
static inline void copy_highpage(struct page *to, struct page *from)
{
	...
}
#define copy_highpage copy_highpage

As is happening in [patch 07/11].

And a similar change could be made to [patch 02/11], actually.


Either way,

Acked-by: Andrew Morton <akpm@linux-foundation.org>
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 776f90f3a1cd..0690679832d4 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -237,6 +237,8 @@  static inline void copy_user_highpage(struct page *to, struct page *from,
 
 #endif
 
+#ifndef __HAVE_ARCH_COPY_HIGHPAGE
+
 static inline void copy_highpage(struct page *to, struct page *from)
 {
 	char *vfrom, *vto;
@@ -248,4 +250,6 @@  static inline void copy_highpage(struct page *to, struct page *from)
 	kunmap_atomic(vfrom);
 }
 
+#endif
+
 #endif /* _LINUX_HIGHMEM_H */