All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com,
	linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com,
	mhocko@suse.com, linux-mm@kvack.org, dan.j.williams@intel.com,
	jack@suse.cz, jglisse@redhat.com, jrdr.linux@gmail.com,
	bhe@redhat.com, gregkh@linuxfoundation.org, vbabka@suse.cz,
	richard.weiyang@gmail.com, dave.hansen@intel.com,
	rientjes@google.com, mingo@kernel.org,
	osalvador@techadventures.net, abdhalee@linux.vnet.ibm.com,
	mpe@ellerman.id.au
Subject: Re: [PATCH v5 1/5] mm/sparse: abstract sparse buffer allocations
Date: Thu, 12 Jul 2018 15:45:52 -0700	[thread overview]
Message-ID: <20180712154552.db99d1893bcba7f9503534a0@linux-foundation.org> (raw)
In-Reply-To: <20180712203730.8703-2-pasha.tatashin@oracle.com>

On Thu, 12 Jul 2018 16:37:26 -0400 Pavel Tatashin <pasha.tatashin@oracle.com> wrote:

> When struct pages are allocated for sparse-vmemmap VA layout, we first
> try to allocate one large buffer, and than if that fails allocate struct
> pages for each section as we go.
> 
> The code that allocates buffer is uses global variables and is spread
> across several call sites.
> 
> Cleanup the code by introducing three functions to handle the global
> buffer:
> 
> sparse_buffer_init()	initialize the buffer
> sparse_buffer_fini()	free the remaining part of the buffer
> sparse_buffer_alloc()	alloc from the buffer, and if buffer is empty
> return NULL
> 
> Define these functions in sparse.c instead of sparse-vmemmap.c because
> later we will use them for non-vmemmap sparse allocations as well.
> 
> ...
>
> +void * __meminit sparse_buffer_alloc(unsigned long size)
> +{
> +	void *ptr = NULL;
> +
> +	if (sparsemap_buf) {
> +		ptr = (void *)ALIGN((unsigned long)sparsemap_buf, size);
> +		if (ptr + size > sparsemap_buf_end)
> +			ptr = NULL;
> +		else
> +			sparsemap_buf = ptr + size;
> +	}
> +	return ptr;
> +}

tweak...

diff -puN mm/sparse.c~mm-sparse-abstract-sparse-buffer-allocations-fix mm/sparse.c
--- a/mm/sparse.c~mm-sparse-abstract-sparse-buffer-allocations-fix
+++ a/mm/sparse.c
@@ -491,7 +491,7 @@ void * __meminit sparse_buffer_alloc(uns
 	void *ptr = NULL;
 
 	if (sparsemap_buf) {
-		ptr = (void *)ALIGN((unsigned long)sparsemap_buf, size);
+		ptr = PTR_ALIGN(sparsemap_buf, size);
 		if (ptr + size > sparsemap_buf_end)
 			ptr = NULL;
 		else


  reply	other threads:[~2018-07-12 22:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 20:37 [PATCH v5 0/5] sparse_init rewrite Pavel Tatashin
2018-07-12 20:37 ` [PATCH v5 1/5] mm/sparse: abstract sparse buffer allocations Pavel Tatashin
2018-07-12 22:45   ` Andrew Morton [this message]
2018-07-13 13:17   ` Oscar Salvador
2018-07-13 13:24     ` Pavel Tatashin
2018-07-13 20:02       ` Andrew Morton
2018-07-12 20:37 ` [PATCH v5 2/5] mm/sparse: use the new sparse buffer functions in non-vmemmap Pavel Tatashin
2018-07-12 20:37 ` [PATCH v5 3/5] mm/sparse: move buffer init/fini to the common place Pavel Tatashin
2018-07-12 20:37 ` [PATCH v5 4/5] mm/sparse: add new sparse_init_nid() and sparse_init() Pavel Tatashin
2018-07-13 12:03   ` Oscar Salvador
2018-07-13 12:37     ` Pavel Tatashin
2018-07-12 20:37 ` [PATCH v5 5/5] mm/sparse: delete old sprase_init and enable new one Pavel Tatashin
2018-07-13  9:09   ` Oscar Salvador
2018-07-13  9:09     ` Oscar Salvador
2018-07-13 11:15     ` Pavel Tatashin
2018-07-13  9:59 ` [PATCH v5 0/5] sparse_init rewrite Oscar Salvador
2018-07-13 11:10   ` Pavel Tatashin
2018-07-16  6:40     ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180712154552.db99d1893bcba7f9503534a0@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=abdhalee@linux.vnet.ibm.com \
    --cc=bhe@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=dave.hansen@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jglisse@redhat.com \
    --cc=jrdr.linux@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=osalvador@techadventures.net \
    --cc=pasha.tatashin@oracle.com \
    --cc=richard.weiyang@gmail.com \
    --cc=rientjes@google.com \
    --cc=steven.sistare@oracle.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.