On 09/13/2013 02:19 AM, KOSAKI Motohiro wrote: >> BTW: in my opinion, within mpol_to_str(), the VM_BUG_ON() need be >> replaced by returning -EINVAL. > > Nope. mpol_to_str() is not carefully designed since it was born. It > doesn't have a way to get proper buffer size. That said, the function > assume all caller know proper buffer size. So, just adding EINVAL > doesn't solve anything. we need to add a way to get proper buffer length > at least if we take your way. However it is overengineering because > current all caller doesn't need it. > That sounds reasonable. Hmm... but I still believe there must be a fixing way to satisfy us all. Please check the patch below whether can satisfy us all, thanks. -------------------------------patch begin----------------------------- mm/shmem.c: use VM_BUG_ON() for mpol_to_str() when it fails. mpol_to_str() is an extern function which may return a failure. But in our case, it should not, If it really return a failure, that means current kernel is continuing blindly (e.g. some kernel structures are corrupted), should be stopped as soon as possible. Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx> --- mm/shmem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 8612a95..3f81120 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -890,7 +890,7 @@ static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol) if (!mpol || mpol->mode == MPOL_DEFAULT) return; /* show nothing */ - mpol_to_str(buffer, sizeof(buffer), mpol); + VM_BUG_ON(mpol_to_str(buffer, sizeof(buffer), mpol) < 0); seq_printf(seq, ",mpol=%s", buffer); } -- 1.7.7.6 -------------------------------patch end------------------------------- Thanks. -- Chen Gang -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>