Re: [PATCH v2 0/4] Introduce the Counter character device interface

From: William Breathitt Gray
Date: Tue Jun 02 2020 - 11:46:44 EST


On Tue, Jun 02, 2020 at 10:18:07AM -0500, David Lechner wrote:
> On 5/31/20 12:14 PM, William Breathitt Gray wrote:
> > Yielding the following /dev/counter0 memory layout:
> >
> > +------------+-----------------+------------+-------------------+
> > | Byte 0 | Byte 1 - Byte 8 | Byte 9 | Byte 10 - Byte 17 |
> > +------------+-----------------+------------+-------------------+
> > | Boundary 0 | Count 0 | Boundary 1 | Count 1 |
> > +------------+-----------------+------------+-------------------+
>
> A potential pitfall with this sort of packing is that some platforms
> do not support unaligned access, so data would have to be "unpacked"
> before it could be used.

Since the user defines the format of this data, they could reorganize it
to a more streamline alignment; for example:

# echo "C0 C1 C0E0 C1E0" > counter0/chrdev_format

Yielding the following /dev/counter0 memory layout instead:

+-----------------+------------------+------------+------------+
| Byte 0 - Byte 7 | Byte 8 - Byte 15 | Byte 16 | Byte 17 |
+-----------------+------------------+------------+------------+
| Count 0 | Count 1 | Boundary 0 | Boundary 1 |
+-----------------+------------------+------------+------------+

In the future, we could also define a padding argument to give users
more control over the exact offsets:

# echo "C0E0 P7 C0 C1E0 P7 C1" > counter0/chrdev_format

Yielding the following /dev/counter0 memory layout instead:

+------------+-----------------+------------------+------------+
| Byte 0 | Byte 1 - Byte 7 | Byte 8 - Byte 15 | Byte 16 |
+------------+-----------------+------------------+------------+
| Boundary 0 | Padding | Count 0 | Boundary 1 |
+------------+-----------------+------------------+------------+
+-------------------+-------------------+
| Byte 17 - Byte 23 | Byte 24 - Byte 31 |
+-------------------+-------------------+
| Padding | Count 1 |
+-------------------+-------------------+

I not sure it's best to introduce padding support with this patchset
given how much is already changing, but I don't anticipate packing
alignment to be something difficult to support in the future with this
interface.

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature