From: Christoph Hellwig <hch@infradead.org>
To: alexjlzheng@gmail.com
Cc: chandan.babu@oracle.com, djwong@kernel.org,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
alexjlzheng@tencent.com
Subject: Re: [PATCH] xfs: make xfs_log_iovec independent from xfs_log_vec and release it early
Date: Tue, 25 Jun 2024 04:33:00 -0700 [thread overview]
Message-ID: <Znqq7GUFnwFj-SFI@infradead.org> (raw)
In-Reply-To: <20240623123119.3562031-1-alexjlzheng@tencent.com>
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -2526,6 +2526,8 @@ xlog_write(
> xlog_write_full(lv, ticket, iclog, &log_offset,
> &len, &record_cnt, &data_cnt);
> }
> + if (lv->lv_flags & XFS_LOG_VEC_DYNAMIC)
> + kvfree(lv->lv_iovecp);
This should porbably be a function paramter to xlog_write, with
xlog_cil_write_chain asking for the iovecs to be freed because they
are dynamically allocated, and the other two not becaue the iovecs
are on-stack. With that we don't need to grow a new field in
struct xfs_log_vec.
> list_for_each_entry(lip, &tp->t_items, li_trans) {
> struct xfs_log_vec *lv;
> + struct xfs_log_iovec *lvec;
> int niovecs = 0;
> int nbytes = 0;
> int buf_size;
> @@ -339,18 +339,23 @@ xlog_cil_alloc_shadow_bufs(
> * the buffer, only the log vector header and the iovec
> * storage.
> */
> - kvfree(lip->li_lv_shadow);
> - lv = xlog_kvmalloc(buf_size);
> -
> - memset(lv, 0, xlog_cil_iovec_space(niovecs));
> + if (lip->li_lv_shadow) {
> + kvfree(lip->li_lv_shadow->lv_iovecp);
> + kvfree(lip->li_lv_shadow);
> + }
> + lv = xlog_kvmalloc(sizeof(struct xfs_log_vec));
> + memset(lv, 0, sizeof(struct xfs_log_vec));
> + lvec = xlog_kvmalloc(buf_size);
> + memset(lvec, 0, xlog_cil_iovec_space(niovecs));
This area can use quite a bit of a redo. The xfs_log_vec is tiny,
so it doesn't really need a vmalloc fallback but can simply use
kmalloc.
But more importantly there is no need to really it, you just
need to allocate it. So this should probably become:
lv = lip->li_lv_shadow;
if (!lv) {
/* kmalloc and initialize, set lv_size to zero */
}
if (buf_size > lv->lv_size) {
/* grow case that rallocates ->lv_iovecp */
} else {
/* same or smaller, optimise common overwrite case */
..
}
next prev parent reply other threads:[~2024-06-25 11:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-23 12:31 [PATCH] xfs: make xfs_log_iovec independent from xfs_log_vec and release it early alexjlzheng
2024-06-24 15:25 ` Darrick J. Wong
2024-06-24 16:06 ` Jinliang Zheng
2024-06-25 11:14 ` Christoph Hellwig
2024-06-25 11:24 ` alexjlzheng
2024-06-25 11:34 ` Christoph Hellwig
2024-06-25 11:33 ` Christoph Hellwig [this message]
2024-06-26 5:07 ` Jinliang Zheng
2024-06-25 21:56 ` kernel test robot
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=Znqq7GUFnwFj-SFI@infradead.org \
--to=hch@infradead.org \
--cc=alexjlzheng@gmail.com \
--cc=alexjlzheng@tencent.com \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).