Return-Path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33619 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031313AbdEXTgd (ORCPT ); Wed, 24 May 2017 15:36:33 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4OJYM5q120011 for ; Wed, 24 May 2017 15:36:33 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2an7nxm2nv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 24 May 2017 15:36:33 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 24 May 2017 16:36:30 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4OJaQ0r31654126 for ; Wed, 24 May 2017 16:36:26 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4OJaQw5004082 for ; Wed, 24 May 2017 16:36:27 -0300 From: Mauricio Faria de Oliveira To: bcrl@kvack.org, viro@zeniv.linux.org.uk Cc: jmoyer@redhat.com, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org Subject: [RESEND PATCH v2 0/2] aio: decouple ctx's max_reqs and nr_events Date: Wed, 24 May 2017 16:36:23 -0300 Message-Id: <1495654585-22790-1-git-send-email-mauricfo@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Currently, using smaller nr_events in io_setup(), the max number of allocation requests is inversely proportional to num_possible_cpus() (which is a problem on larger/non-virtualized systems with many CPUs). This happens because, internally, nr_events must be increased for the percpu allocation scheme (according to the number of CPUs), but it is being reflected on the max_reqs value (aio-nr), which is used to count against the global limit (aio-max-nr). This patchset decouples ctx->max_reqs and ctx->nr_events, so that the extra nr_events which are internally required do not reflect into the 'aio-nr' counter which is externally visible & checked to 'aio-max-nr'. This ensures that userspace can allocate most of the aio-max-nr value that is made available/visible to it -- regardless of the number of possible CPUs in the system. P.S.: this patchset has been 'relatively acked' by Benjamin LaHaise [2], but for timing difficulties, it hasn't been queued nor re-submitted in a while; sorry. v2: - adjust/move comment in PATCH 2/2 to commit message (Jeff Moyer [3]) Test-case: // 64k request (ie, aio-max-nr) to io_setup with nr_events = 1 for (i = 0; i < 65536; i++) if (rc = io_setup(1, &ioctx[i])) break; printf("rc = %d, i = %d\n", rc, i); - on v4.12-rc2, it fails w/ -EAGAIN on request #102 (160 CPUs), and aio-nr value is ~2x the aio-max-nr value (wrong): # ./test-case & rc = -11, i = 102 # grep . /proc/sys/fs/aio-* /proc/sys/fs/aio-max-nr:65536 /proc/sys/fs/aio-nr:130560 - on v4.12-rc2 with patches, it fails w/ -ENOMEM on request #65515, thus going way further toward the actual max limit: # ./test-case & rc = -12, i = 65515 # grep . /proc/sys/fs/aio-* /proc/sys/fs/aio-max-nr:65536 /proc/sys/fs/aio-nr:65515 Links: [1] http://marc.info/?l=linux-aio&m=147562172703469&w=2 [2] http://marc.info/?l=linux-aio&m=147757894603034&w=2 [3] http://marc.info/?l=linux-aio&m=147769074702475&w=2 Mauricio Faria de Oliveira (2): aio: make nr_events a parameter for aio_setup_ring() aio: use ctx->max_reqs only for counting against the global limit fs/aio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 1.8.3.1