* [PATCH]: Let I/O engine provide methods to allocate/free I/O memory.
@ 2016-02-23 21:16 Andrey Kuzmin
2016-02-23 21:57 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Andrey Kuzmin @ 2016-02-23 21:16 UTC (permalink / raw)
To: Jens Axboe; +Cc: fio@vger.kernel.org
[-- Attachment #1.1: Type: text/plain, Size: 1897 bytes --]
I/O engine may have special needs as to how the I/O memory should be
allocated. The below patch adds respective methods to the I/O engine
interface.
Regards,
Andrey
diff --git a/ioengine.h b/ioengine.h
index 6734c7b..161acf5 100644
--- a/ioengine.h
+++ b/ioengine.h
@@ -16,7 +16,7 @@
#include <guasi.h>
#endif
-#define FIO_IOOPS_VERSION 22
+#define FIO_IOOPS_VERSION 23
enum {
IO_U_F_FREE = 1 << 0,
@@ -157,6 +157,8 @@ struct ioengine_ops {
int (*unlink_file)(struct thread_data *, struct fio_file *);
int (*get_file_size)(struct thread_data *, struct fio_file *);
void (*terminate)(struct thread_data *);
+ int (*iomem_alloc)(struct thread_data *, size_t);
+ void (*iomem_free)(struct thread_data *);
int (*io_u_init)(struct thread_data *, struct io_u *);
void (*io_u_free)(struct thread_data *, struct io_u *);
int option_struct_size;
diff --git a/memory.c b/memory.c
index 5060223..4d5d474 100644
--- a/memory.c
+++ b/memory.c
@@ -229,7 +229,9 @@ int allocate_io_mem(struct thread_data *td)
dprint(FD_MEM, "Alloc %llu for buffers\n", (unsigned long long)
total_mem);
- if (td->o.mem_type == MEM_MALLOC)
+ if (td->io_ops->iomem_alloc)
+ ret = td->io_ops->iomem_alloc(td, total_mem);
+ else if (td->o.mem_type == MEM_MALLOC)
ret = alloc_mem_malloc(td, total_mem);
else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
ret = alloc_mem_shm(td, total_mem);
@@ -255,7 +257,9 @@ void free_io_mem(struct thread_data *td)
if (td->o.odirect || td->o.oatomic)
total_mem += page_mask;
- if (td->o.mem_type == MEM_MALLOC)
+ if (td->io_ops->iomem_free)
+ td->io_ops->iomem_free(td);
+ else if (td->o.mem_type == MEM_MALLOC)
free_mem_malloc(td);
else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
free_mem_shm(td);
[-- Attachment #1.2: Type: text/html, Size: 2295 bytes --]
[-- Attachment #2: Let-io-engine-allocate-io-memory.patch --]
[-- Type: text/x-patch, Size: 1624 bytes --]
diff --git a/ioengine.h b/ioengine.h
index 6734c7b..161acf5 100644
--- a/ioengine.h
+++ b/ioengine.h
@@ -16,7 +16,7 @@
#include <guasi.h>
#endif
-#define FIO_IOOPS_VERSION 22
+#define FIO_IOOPS_VERSION 23
enum {
IO_U_F_FREE = 1 << 0,
@@ -157,6 +157,8 @@ struct ioengine_ops {
int (*unlink_file)(struct thread_data *, struct fio_file *);
int (*get_file_size)(struct thread_data *, struct fio_file *);
void (*terminate)(struct thread_data *);
+ int (*iomem_alloc)(struct thread_data *, size_t);
+ void (*iomem_free)(struct thread_data *);
int (*io_u_init)(struct thread_data *, struct io_u *);
void (*io_u_free)(struct thread_data *, struct io_u *);
int option_struct_size;
diff --git a/memory.c b/memory.c
index 5060223..4d5d474 100644
--- a/memory.c
+++ b/memory.c
@@ -229,7 +229,9 @@ int allocate_io_mem(struct thread_data *td)
dprint(FD_MEM, "Alloc %llu for buffers\n", (unsigned long long) total_mem);
- if (td->o.mem_type == MEM_MALLOC)
+ if (td->io_ops->iomem_alloc)
+ ret = td->io_ops->iomem_alloc(td, total_mem);
+ else if (td->o.mem_type == MEM_MALLOC)
ret = alloc_mem_malloc(td, total_mem);
else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
ret = alloc_mem_shm(td, total_mem);
@@ -255,7 +257,9 @@ void free_io_mem(struct thread_data *td)
if (td->o.odirect || td->o.oatomic)
total_mem += page_mask;
- if (td->o.mem_type == MEM_MALLOC)
+ if (td->io_ops->iomem_free)
+ td->io_ops->iomem_free(td);
+ else if (td->o.mem_type == MEM_MALLOC)
free_mem_malloc(td);
else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE)
free_mem_shm(td);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH]: Let I/O engine provide methods to allocate/free I/O memory.
2016-02-23 21:16 [PATCH]: Let I/O engine provide methods to allocate/free I/O memory Andrey Kuzmin
@ 2016-02-23 21:57 ` Jens Axboe
2016-02-23 22:02 ` Andrey Kuzmin
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2016-02-23 21:57 UTC (permalink / raw)
To: Andrey Kuzmin; +Cc: fio@vger.kernel.org
On 02/23/2016 02:16 PM, Andrey Kuzmin wrote:
> I/O engine may have special needs as to how the I/O memory should be
> allocated. The below patch adds respective methods to the I/O engine
> interface.
What kind of special needs? It's not that I mind adding an IO engine
alloc hook, the only issue is that it potentially voids the various job
file settings for memory backing etc without the user knowing it. So I
think we need some decent justification here, other than "special needs" :-)
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH]: Let I/O engine provide methods to allocate/free I/O memory.
2016-02-23 21:57 ` Jens Axboe
@ 2016-02-23 22:02 ` Andrey Kuzmin
2016-02-23 22:04 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Andrey Kuzmin @ 2016-02-23 22:02 UTC (permalink / raw)
To: Jens Axboe; +Cc: fio
[-- Attachment #1: Type: text/plain, Size: 748 bytes --]
On Feb 24, 2016 00:57, "Jens Axboe" <axboe@kernel.dk> wrote:
>
> On 02/23/2016 02:16 PM, Andrey Kuzmin wrote:
>>
>> I/O engine may have special needs as to how the I/O memory should be
>> allocated. The below patch adds respective methods to the I/O engine
>> interface.
>
>
> What kind of special needs? It's not that I mind adding an IO engine
alloc hook, the only issue is that it potentially voids the various job
file settings for memory backing etc without the user knowing it. So I
think we need some decent justification here, other than "special needs" :-)
>
My engine talks directly to the hardware, and has to comply with the
hardware requirements re the io memory. Is that enough justification ;)?
Regards,
A.
>
>
> --
> Jens Axboe
>
[-- Attachment #2: Type: text/html, Size: 1017 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH]: Let I/O engine provide methods to allocate/free I/O memory.
2016-02-23 22:02 ` Andrey Kuzmin
@ 2016-02-23 22:04 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2016-02-23 22:04 UTC (permalink / raw)
To: Andrey Kuzmin; +Cc: fio
On 02/23/2016 03:02 PM, Andrey Kuzmin wrote:
>
> On Feb 24, 2016 00:57, "Jens Axboe" <axboe@kernel.dk
> <mailto:axboe@kernel.dk>> wrote:
> >
> > On 02/23/2016 02:16 PM, Andrey Kuzmin wrote:
> >>
> >> I/O engine may have special needs as to how the I/O memory should be
> >> allocated. The below patch adds respective methods to the I/O engine
> >> interface.
> >
> >
> > What kind of special needs? It's not that I mind adding an IO engine
> alloc hook, the only issue is that it potentially voids the various job
> file settings for memory backing etc without the user knowing it. So I
> think we need some decent justification here, other than "special needs" :-)
> >
>
> My engine talks directly to the hardware, and has to comply with the
> hardware requirements re the io memory. Is that enough justification ;)?
Maybe :-)
What are those requirements? Is it just alignment?
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-23 22:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-23 21:16 [PATCH]: Let I/O engine provide methods to allocate/free I/O memory Andrey Kuzmin
2016-02-23 21:57 ` Jens Axboe
2016-02-23 22:02 ` Andrey Kuzmin
2016-02-23 22:04 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox