Skip to content

Commit e678900

Browse files
raeburnMikulas Patocka
authored andcommitted
dm vdo indexer: reorder uds_request to reduce padding
Reorder fields and make uds_request_type and uds_zone_message packed, to squeeze out some space. Use struct_group so the request reset code no longer needs to care about field order. On x86_64 this reduces the struct size from 144 to 120, which saves 48 kB (about 12%) per VDO hash zone. Signed-off-by: Ken Raeburn <[email protected]> Signed-off-by: Matthew Sakai <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 88f7f56 commit e678900

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

drivers/md/dm-vdo/indexer/index-session.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ static int get_index_session(struct uds_index_session *index_session)
100100

101101
int uds_launch_request(struct uds_request *request)
102102
{
103-
size_t internal_size;
104103
int result;
105104

106105
if (request->callback == NULL) {
@@ -121,10 +120,7 @@ int uds_launch_request(struct uds_request *request)
121120
}
122121

123122
/* Reset all internal fields before processing. */
124-
internal_size =
125-
sizeof(struct uds_request) - offsetof(struct uds_request, zone_number);
126-
// FIXME should be using struct_group for this instead
127-
memset((char *) request + sizeof(*request) - internal_size, 0, internal_size);
123+
memset(&request->internal, 0, sizeof(request->internal));
128124

129125
result = get_index_session(request->session);
130126
if (result != UDS_SUCCESS)

drivers/md/dm-vdo/indexer/indexer.h

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/mutex.h>
1010
#include <linux/sched.h>
11+
#include <linux/stddef.h>
1112
#include <linux/types.h>
1213
#include <linux/wait.h>
1314

@@ -73,7 +74,7 @@ enum uds_request_type {
7374
/* Remove any mapping for a name. */
7475
UDS_DELETE,
7576

76-
};
77+
} __packed;
7778

7879
enum uds_open_index_type {
7980
/* Create a new index. */
@@ -226,7 +227,7 @@ struct uds_zone_message {
226227
enum uds_zone_message_type type;
227228
/* The virtual chapter number to which the message applies */
228229
u64 virtual_chapter;
229-
};
230+
} __packed;
230231

231232
struct uds_index_session;
232233
struct uds_index;
@@ -253,34 +254,32 @@ struct uds_request {
253254

254255
/* The existing data associated with the request name, if any */
255256
struct uds_record_data old_metadata;
256-
/* Either UDS_SUCCESS or an error code for the request */
257-
int status;
258257
/* True if the record name had an existing entry in the index */
259258
bool found;
259+
/* Either UDS_SUCCESS or an error code for the request */
260+
int status;
260261

261-
/*
262-
* The remaining fields are used internally and should not be altered by clients. The index
263-
* relies on zone_number being the first field in this section.
264-
*/
265-
266-
/* The number of the zone which will process this request*/
267-
unsigned int zone_number;
268-
/* A link for adding a request to a lock-free queue */
269-
struct funnel_queue_entry queue_link;
270-
/* A link for adding a request to a standard linked list */
271-
struct uds_request *next_request;
272-
/* A pointer to the index processing this request */
273-
struct uds_index *index;
274-
/* Control message for coordinating between zones */
275-
struct uds_zone_message zone_message;
276-
/* If true, process request immediately by waking the worker thread */
277-
bool unbatched;
278-
/* If true, continue this request before processing newer requests */
279-
bool requeued;
280-
/* The virtual chapter containing the record name, if known */
281-
u64 virtual_chapter;
282-
/* The region of the index containing the record name */
283-
enum uds_index_region location;
262+
/* The remaining fields are used internally and should not be altered by clients. */
263+
struct_group(internal,
264+
/* The virtual chapter containing the record name, if known */
265+
u64 virtual_chapter;
266+
/* The region of the index containing the record name */
267+
enum uds_index_region location;
268+
/* If true, process request immediately by waking the worker thread */
269+
bool unbatched;
270+
/* If true, continue this request before processing newer requests */
271+
bool requeued;
272+
/* Control message for coordinating between zones */
273+
struct uds_zone_message zone_message;
274+
/* The number of the zone which will process this request*/
275+
unsigned int zone_number;
276+
/* A link for adding a request to a lock-free queue */
277+
struct funnel_queue_entry queue_link;
278+
/* A link for adding a request to a standard linked list */
279+
struct uds_request *next_request;
280+
/* A pointer to the index processing this request */
281+
struct uds_index *index;
282+
);
284283
};
285284

286285
/* A session is required for most index operations. */

0 commit comments

Comments
 (0)