xiaoxiang781216 commented on code in PR #8000: URL: https://github.com/apache/nuttx/pull/8000#discussion_r1059943209
########## include/nuttx/mm/mm_map.h: ########## @@ -0,0 +1,83 @@ +/**************************************************************************** + * include/nuttx/mm/mm_map.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_MM_MM_MAP_H +#define __INCLUDE_NUTTX_MM_MM_MAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/fs/fs.h> +#include <nuttx/queue.h> + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* Type of the mapping */ + +enum mm_map_type +{ + MM_MAP_ANONYMOUS, + MM_MAP_NAMED, + MM_MAP_INODE, + MM_MAP_SHM +}; + +/* Id of the mapping */ + +union mm_map_id_u +{ + FAR const char *name; /* For MM_MAP_NAMED */ + FAR struct inode *inode; /* For MM_MAP_INODE */ + int shmid; /* FOR MM_MAP_SHM */ + uintptr_t val; +}; + +/* A memory mapping list item */ + +struct mm_map_entry_s +{ + FAR struct mm_map_entry *flink; /* this is used as sq_entry_t */ + enum mm_map_type type; + union mm_map_id_u id; Review Comment: User may call close before munmap, so it's better to move munmap callback to mm_map_entry_s and remove type and id field. BTW, this change makes the design is almost same as Linux: 1. file_operations only contain mmap callback and vm_area_struct contain all information: https://github.com/torvalds/linux/blob/master/include/linux/fs.h#L2102 https://github.com/torvalds/linux/blob/master/include/linux/mm_types.h#L535-L598 2. Other callbacks are pointed by vm_area_struct::vm_ops https://github.com/torvalds/linux/blob/master/include/linux/mm.h#L540-L612 Since our case is very simple, it looks reasonable to skip vm_operations_struct and put callback into vm_map_entry_s directly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org