linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] what to do with IOCB_DSYNC?
@ 2021-06-21  0:46 Al Viro
  2021-06-21 13:59 ` Christoph Hellwig
  0 siblings, 1 reply; 60+ messages in thread
From: Al Viro @ 2021-06-21  0:46 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Christoph Hellwig, Jens Axboe

	dde0c2e79848 "fs: add IOCB_SYNC and IOCB_DSYNC" had
done this
+       if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
+               res |= IOCB_DSYNC;

in iocb_flags().  The first half is not a problem.  However,
if you look at the second one, you'll see fetches from
file->f_mapping->host->i_flags and, worse yet,
file->f_mapping->host->i_sb->s_flags.  Now, ->f_mapping might
be within the cacheline we'd already fetched from.  However,
->f_mapping->host and ->f_mapping->host->i_flags are in
different cachelines (i_data.host and i_flags in some struct inode
instance).  ->host->i_sb is in the same cacheline as ->host->i_flags,
but ->host->i_sb->s_flags is certain to bring yet another cacheline
into the picture.

IOW, it's not going to be cheap, no matter what we do.  Moreover,
that thing used to live in generic_write_sync() and used only by
the ->write_iter() instances that knew they would care about it.
Now it's used by all ->write_iter() and ->read_iter() callers.

How about the following:
	* new flag: IOCB_DSYNC_KNOWN
	* in iocb_flags(), O_DSYNC => IOCB_SYNC_KNOWN | IOCB_DSYNC
	* ditto for places explicitly setting IOCB_DSYNC
	* places checking IOCB_DSYNC use
static inline bool iocb_is_dsync(struct kiocb *iocb)
{
	if (likely(iocb->ki_flags & IOCB_DSYNC_KNOWN))
		return iocb->ki_flags & IOCB_DSYNC;
	if (unlikely(IS_SYNC(iocb->ki_filp->f_mapping->host))
		iocb->ki_flags |= IOCB_DSYNC_KNOWN | IOCB_DSYNC;
		return true;
	}
	iocb->ki_flags |= IOCB_DSYNC_KNOWN;
	return false;
}
instead
	That way init_sync_kiocb() becomes much lighter, especially
if we cache its value in struct file - there are very few places where
it can change.  Comments?

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2022-05-28 20:55 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21  0:46 [RFC] what to do with IOCB_DSYNC? Al Viro
2021-06-21 13:59 ` Christoph Hellwig
2021-06-21 14:03   ` Matthew Wilcox
2021-06-21 14:09     ` Christoph Hellwig
2021-06-21 14:16       ` Matthew Wilcox
2021-06-21 14:22         ` Christoph Hellwig
2021-06-21 14:32           ` Al Viro
2021-06-21 14:35             ` Christoph Hellwig
2021-06-21 15:22               ` Jens Axboe
2022-05-21 17:48               ` Al Viro
2022-05-21 19:03                 ` Jens Axboe
2022-05-21 22:14                   ` Jens Axboe
2022-05-22  7:45                     ` Christoph Hellwig
2022-05-22 10:23                       ` Matthew Wilcox
2022-05-22 10:36                         ` Al Viro
2022-05-22 11:15                           ` Matthew Wilcox
2022-05-22 11:45                             ` Christoph Hellwig
2022-05-22 12:39                               ` Jens Axboe
2022-05-22 12:48                                 ` Al Viro
2022-05-22 13:02                                   ` Jens Axboe
2022-05-22 13:07                                     ` Al Viro
2022-05-22 13:09                                       ` Jens Axboe
2022-05-22 18:06                                         ` Jens Axboe
2022-05-22 18:25                                           ` Al Viro
2022-05-22 18:29                                             ` Jens Axboe
2022-05-22 18:39                                               ` Al Viro
2022-05-22 18:48                                                 ` Jens Axboe
2022-05-22 19:04                                                   ` Al Viro
2022-05-22 20:03                                                     ` Jens Axboe
2022-05-23  0:42                                                       ` Al Viro
2022-05-23  1:22                                                         ` Jens Axboe
2022-05-23  1:28                                                           ` Jens Axboe
2022-05-23  1:50                                                             ` Jens Axboe
2022-05-23  2:43                                                               ` Jens Axboe
2022-05-23 14:22                                                                 ` Al Viro
2022-05-23 14:34                                                                   ` Jens Axboe
2022-05-23 14:47                                                                     ` Al Viro
2022-05-23 15:12                                                                       ` Jens Axboe
2022-05-23 15:44                                                                         ` Jens Axboe
2022-05-23 15:49                                                                           ` Matthew Wilcox
2022-05-23 15:55                                                                             ` Jens Axboe
2022-05-23 16:03                                                                               ` Jens Axboe
2022-05-26 14:46                                                                                 ` Jason A. Donenfeld
2022-05-27 10:09                                                                                   ` Ingo Molnar
2022-05-27 10:15                                                                                     ` Jason A. Donenfeld
2022-05-27 14:45                                                                                       ` Samuel Neves
2022-05-27 10:25                                                                                     ` Ingo Molnar
2022-05-27 10:36                                                                                       ` Borislav Petkov
2022-05-28 20:54                                                                                         ` Sedat Dilek
2022-05-28 20:38                                                                                       ` Sedat Dilek
2022-05-28 20:39                                                                                         ` Sedat Dilek
2022-05-23 16:15                                                                         ` Al Viro
2022-05-25 14:34                                                         ` Matthew Wilcox
2022-05-26 23:19                                                     ` Al Viro
2022-05-27 14:51                                                       ` Jens Axboe
2022-05-22 12:21                             ` Al Viro
2022-05-22  7:43                 ` Christoph Hellwig
2022-05-22 12:41                   ` Al Viro
2022-05-22 12:51                     ` Christoph Hellwig
2021-06-21 14:22       ` Al Viro

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).