Re: [PATCH v2 1/4] mm: Fix multiple evaluvations of totalram_pages and managed_pages

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

 



Hi Arun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.20-rc1 next-20181107]
[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/Arun-KS/mm-Fix-multiple-evaluvations-of-totalram_pages-and-managed_pages/20181108-025657
config: i386-randconfig-x014-201844 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/export.h:45:0,
                    from include/linux/linkage.h:7,
                    from include/linux/kernel.h:7,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from net/sctp/protocol.c:44:
   net/sctp/protocol.c: In function 'sctp_init':
   net/sctp/protocol.c:1430:6: error: 'totalram_pgs' undeclared (first use in this function); did you mean 'totalram_pages'?
     if (totalram_pgs >= (128 * 1024))
         ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/sctp/protocol.c:1430:2: note: in expansion of macro 'if'
     if (totalram_pgs >= (128 * 1024))
     ^~
   net/sctp/protocol.c:1430:6: note: each undeclared identifier is reported only once for each function it appears in
     if (totalram_pgs >= (128 * 1024))
         ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/sctp/protocol.c:1430:2: note: in expansion of macro 'if'
     if (totalram_pgs >= (128 * 1024))
     ^~
   net/sctp/protocol.c:1371:16: warning: unused variable 'totalram_pages' [-Wunused-variable]
     unsigned long totalram_pages;
                   ^~~~~~~~~~~~~~

vim +/if +1430 net/sctp/protocol.c

  1363	
  1364	/* Initialize the universe into something sensible.  */
  1365	static __init int sctp_init(void)
  1366	{
  1367		int i;
  1368		int status = -EINVAL;
  1369		unsigned long goal;
  1370		unsigned long limit;
  1371		unsigned long totalram_pages;
  1372		int max_share;
  1373		int order;
  1374		int num_entries;
  1375		int max_entry_order;
  1376	
  1377		sock_skb_cb_check_size(sizeof(struct sctp_ulpevent));
  1378	
  1379		/* Allocate bind_bucket and chunk caches. */
  1380		status = -ENOBUFS;
  1381		sctp_bucket_cachep = kmem_cache_create("sctp_bind_bucket",
  1382						       sizeof(struct sctp_bind_bucket),
  1383						       0, SLAB_HWCACHE_ALIGN,
  1384						       NULL);
  1385		if (!sctp_bucket_cachep)
  1386			goto out;
  1387	
  1388		sctp_chunk_cachep = kmem_cache_create("sctp_chunk",
  1389						       sizeof(struct sctp_chunk),
  1390						       0, SLAB_HWCACHE_ALIGN,
  1391						       NULL);
  1392		if (!sctp_chunk_cachep)
  1393			goto err_chunk_cachep;
  1394	
  1395		status = percpu_counter_init(&sctp_sockets_allocated, 0, GFP_KERNEL);
  1396		if (status)
  1397			goto err_percpu_counter_init;
  1398	
  1399		/* Implementation specific variables. */
  1400	
  1401		/* Initialize default stream count setup information. */
  1402		sctp_max_instreams    		= SCTP_DEFAULT_INSTREAMS;
  1403		sctp_max_outstreams   		= SCTP_DEFAULT_OUTSTREAMS;
  1404	
  1405		/* Initialize handle used for association ids. */
  1406		idr_init(&sctp_assocs_id);
  1407	
  1408		limit = nr_free_buffer_pages() / 8;
  1409		limit = max(limit, 128UL);
  1410		sysctl_sctp_mem[0] = limit / 4 * 3;
  1411		sysctl_sctp_mem[1] = limit;
  1412		sysctl_sctp_mem[2] = sysctl_sctp_mem[0] * 2;
  1413	
  1414		/* Set per-socket limits to no more than 1/128 the pressure threshold*/
  1415		limit = (sysctl_sctp_mem[1]) << (PAGE_SHIFT - 7);
  1416		max_share = min(4UL*1024*1024, limit);
  1417	
  1418		sysctl_sctp_rmem[0] = SK_MEM_QUANTUM; /* give each asoc 1 page min */
  1419		sysctl_sctp_rmem[1] = 1500 * SKB_TRUESIZE(1);
  1420		sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share);
  1421	
  1422		sysctl_sctp_wmem[0] = SK_MEM_QUANTUM;
  1423		sysctl_sctp_wmem[1] = 16*1024;
  1424		sysctl_sctp_wmem[2] = max(64*1024, max_share);
  1425	
  1426		/* Size and allocate the association hash table.
  1427		 * The methodology is similar to that of the tcp hash tables.
  1428		 * Though not identical.  Start by getting a goal size
  1429		 */
> 1430		if (totalram_pgs >= (128 * 1024))
  1431			goal = totalram_pgs >> (22 - PAGE_SHIFT);
  1432		else
  1433			goal = totalram_pgs >> (24 - PAGE_SHIFT);
  1434	
  1435		/* Then compute the page order for said goal */
  1436		order = get_order(goal);
  1437	
  1438		/* Now compute the required page order for the maximum sized table we
  1439		 * want to create
  1440		 */
  1441		max_entry_order = get_order(MAX_SCTP_PORT_HASH_ENTRIES *
  1442					    sizeof(struct sctp_bind_hashbucket));
  1443	
  1444		/* Limit the page order by that maximum hash table size */
  1445		order = min(order, max_entry_order);
  1446	
  1447		/* Allocate and initialize the endpoint hash table.  */
  1448		sctp_ep_hashsize = 64;
  1449		sctp_ep_hashtable =
  1450			kmalloc_array(64, sizeof(struct sctp_hashbucket), GFP_KERNEL);
  1451		if (!sctp_ep_hashtable) {
  1452			pr_err("Failed endpoint_hash alloc\n");
  1453			status = -ENOMEM;
  1454			goto err_ehash_alloc;
  1455		}
  1456		for (i = 0; i < sctp_ep_hashsize; i++) {
  1457			rwlock_init(&sctp_ep_hashtable[i].lock);
  1458			INIT_HLIST_HEAD(&sctp_ep_hashtable[i].chain);
  1459		}
  1460	
  1461		/* Allocate and initialize the SCTP port hash table.
  1462		 * Note that order is initalized to start at the max sized
  1463		 * table we want to support.  If we can't get that many pages
  1464		 * reduce the order and try again
  1465		 */
  1466		do {
  1467			sctp_port_hashtable = (struct sctp_bind_hashbucket *)
  1468				__get_free_pages(GFP_KERNEL | __GFP_NOWARN, order);
  1469		} while (!sctp_port_hashtable && --order > 0);
  1470	
  1471		if (!sctp_port_hashtable) {
  1472			pr_err("Failed bind hash alloc\n");
  1473			status = -ENOMEM;
  1474			goto err_bhash_alloc;
  1475		}
  1476	
  1477		/* Now compute the number of entries that will fit in the
  1478		 * port hash space we allocated
  1479		 */
  1480		num_entries = (1UL << order) * PAGE_SIZE /
  1481			      sizeof(struct sctp_bind_hashbucket);
  1482	
  1483		/* And finish by rounding it down to the nearest power of two
  1484		 * this wastes some memory of course, but its needed because
  1485		 * the hash function operates based on the assumption that
  1486		 * that the number of entries is a power of two
  1487		 */
  1488		sctp_port_hashsize = rounddown_pow_of_two(num_entries);
  1489	
  1490		for (i = 0; i < sctp_port_hashsize; i++) {
  1491			spin_lock_init(&sctp_port_hashtable[i].lock);
  1492			INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain);
  1493		}
  1494	
  1495		status = sctp_transport_hashtable_init();
  1496		if (status)
  1497			goto err_thash_alloc;
  1498	
  1499		pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize,
  1500			num_entries);
  1501	
  1502		sctp_sysctl_register();
  1503	
  1504		INIT_LIST_HEAD(&sctp_address_families);
  1505		sctp_v4_pf_init();
  1506		sctp_v6_pf_init();
  1507		sctp_sched_ops_init();
  1508	
  1509		status = register_pernet_subsys(&sctp_defaults_ops);
  1510		if (status)
  1511			goto err_register_defaults;
  1512	
  1513		status = sctp_v4_protosw_init();
  1514		if (status)
  1515			goto err_protosw_init;
  1516	
  1517		status = sctp_v6_protosw_init();
  1518		if (status)
  1519			goto err_v6_protosw_init;
  1520	
  1521		status = register_pernet_subsys(&sctp_ctrlsock_ops);
  1522		if (status)
  1523			goto err_register_ctrlsock;
  1524	
  1525		status = sctp_v4_add_protocol();
  1526		if (status)
  1527			goto err_add_protocol;
  1528	
  1529		/* Register SCTP with inet6 layer.  */
  1530		status = sctp_v6_add_protocol();
  1531		if (status)
  1532			goto err_v6_add_protocol;
  1533	
  1534		if (sctp_offload_init() < 0)
  1535			pr_crit("%s: Cannot add SCTP protocol offload\n", __func__);
  1536	
  1537	out:
  1538		return status;
  1539	err_v6_add_protocol:
  1540		sctp_v4_del_protocol();
  1541	err_add_protocol:
  1542		unregister_pernet_subsys(&sctp_ctrlsock_ops);
  1543	err_register_ctrlsock:
  1544		sctp_v6_protosw_exit();
  1545	err_v6_protosw_init:
  1546		sctp_v4_protosw_exit();
  1547	err_protosw_init:
  1548		unregister_pernet_subsys(&sctp_defaults_ops);
  1549	err_register_defaults:
  1550		sctp_v4_pf_exit();
  1551		sctp_v6_pf_exit();
  1552		sctp_sysctl_unregister();
  1553		free_pages((unsigned long)sctp_port_hashtable,
  1554			   get_order(sctp_port_hashsize *
  1555				     sizeof(struct sctp_bind_hashbucket)));
  1556	err_bhash_alloc:
  1557		sctp_transport_hashtable_destroy();
  1558	err_thash_alloc:
  1559		kfree(sctp_ep_hashtable);
  1560	err_ehash_alloc:
  1561		percpu_counter_destroy(&sctp_sockets_allocated);
  1562	err_percpu_counter_init:
  1563		kmem_cache_destroy(sctp_chunk_cachep);
  1564	err_chunk_cachep:
  1565		kmem_cache_destroy(sctp_bucket_cachep);
  1566		goto out;
  1567	}
  1568	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux