diff mbox series

[mm-unstable,04/17] mm: alpha: Introduce arch_mmap_hint()

Message ID 20241210024119.2488608-5-kaleshsingh@google.com (mailing list archive)
State Superseded
Headers show
Series mm: Introduce arch_mmap_hint() | expand

Commit Message

Kalesh Singh Dec. 10, 2024, 2:41 a.m. UTC
Introduce alpha arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT.
This is a preparatory patch, no functional change is introduced.

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---
 arch/alpha/include/asm/pgtable.h |  1 +
 arch/alpha/kernel/osf_sys.c      | 29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

Comments

kernel test robot Dec. 10, 2024, 11:35 a.m. UTC | #1
Hi Kalesh,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Kalesh-Singh/mm-Introduce-generic_mmap_hint/20241210-104424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20241210024119.2488608-5-kaleshsingh%40google.com
patch subject: [PATCH mm-unstable 04/17] mm: alpha: Introduce arch_mmap_hint()
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20241210/202412102123.Db7EAmhx-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241210/202412102123.Db7EAmhx-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412102123.Db7EAmhx-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/alpha/kernel/osf_sys.c: In function 'arch_get_unmapped_area':
>> arch/alpha/kernel/osf_sys.c:1280:24: error: 'hint' undeclared (first use in this function); did you mean 'uint'?
    1280 |                 return hint;
         |                        ^~~~
         |                        uint
   arch/alpha/kernel/osf_sys.c:1280:24: note: each undeclared identifier is reported only once for each function it appears in


vim +1280 arch/alpha/kernel/osf_sys.c

  1248	
  1249	unsigned long
  1250	arch_get_unmapped_area(struct file *filp, unsigned long addr,
  1251			       unsigned long len, unsigned long pgoff,
  1252			       unsigned long flags, vm_flags_t vm_flags)
  1253	{
  1254		unsigned long limit;
  1255	
  1256		/* "32 bit" actually means 31 bit, since pointers sign extend.  */
  1257		if (current->personality & ADDR_LIMIT_32BIT)
  1258			limit = 0x80000000;
  1259		else
  1260			limit = TASK_SIZE;
  1261	
  1262		if (len > limit)
  1263			return -ENOMEM;
  1264	
  1265		if (flags & MAP_FIXED)
  1266			return addr;
  1267	
  1268		/* First, see if the given suggestion fits.
  1269	
  1270		   The OSF/1 loader (/sbin/loader) relies on us returning an
  1271		   address larger than the requested if one exists, which is
  1272		   a terribly broken way to program.
  1273	
  1274		   That said, I can see the use in being able to suggest not
  1275		   merely specific addresses, but regions of memory -- perhaps
  1276		   this feature should be incorporated into all ports?  */
  1277	
  1278		addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
  1279		if (addr)
> 1280			return hint;
  1281	
  1282		/* Next, try allocating at TASK_UNMAPPED_BASE.  */
  1283		addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
  1284						 len, limit);
  1285		if (addr != (unsigned long) -ENOMEM)
  1286			return addr;
  1287	
  1288		/* Finally, try allocating in low memory.  */
  1289		addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
  1290	
  1291		return addr;
  1292	}
  1293
diff mbox series

Patch

diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
index 635f0a5f5bbd..372885a01abd 100644
--- a/arch/alpha/include/asm/pgtable.h
+++ b/arch/alpha/include/asm/pgtable.h
@@ -362,5 +362,6 @@  extern void paging_init(void);
 
 /* We have our own get_unmapped_area to cope with ADDR_LIMIT_32BIT.  */
 #define HAVE_ARCH_UNMAPPED_AREA
+#define HAVE_ARCH_MMAP_HINT
 
 #endif /* _ALPHA_PGTABLE_H */
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 86185021f75a..68e61dece537 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1225,6 +1225,27 @@  arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
 	return vm_unmapped_area(&info);
 }
 
+unsigned long arch_mmap_hint(struct file *filp, unsigned long addr,
+			     unsigned long len, unsigned long pgoff,
+			     unsigned long flags)
+{
+	unsigned long limit;
+
+	if (!addr)
+		return 0;
+
+	/* "32 bit" actually means 31 bit, since pointers sign extend.  */
+	if (current->personality & ADDR_LIMIT_32BIT)
+		limit = 0x80000000;
+	else
+		limit = TASK_SIZE;
+
+	if (limit - len < addr)
+		return 0;
+
+	return generic_mmap_hint(filp, addr, len, pgoff, flags);
+}
+
 unsigned long
 arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		       unsigned long len, unsigned long pgoff,
@@ -1254,11 +1275,9 @@  arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	   merely specific addresses, but regions of memory -- perhaps
 	   this feature should be incorporated into all ports?  */
 
-	if (addr) {
-		addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
-		if (addr != (unsigned long) -ENOMEM)
-			return addr;
-	}
+	addr = arch_mmap_hint(filp, addr, len, pgoff, flags);
+	if (addr)
+		return hint;
 
 	/* Next, try allocating at TASK_UNMAPPED_BASE.  */
 	addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),